is-valid-package-name
v1.0.0
Published
Validation for package name
Downloads
8
Maintainers
Readme
A validator collection of package names for each package registry
:sparkles: Features
- :zap: Multi runtime support (
Deno
,Node.js
) - :books: Pure TypeScript and provides type definition
- :package: Optimized, super slim size
- :page_facing_up: TSDoc-style comments
Currently providing validators for the following package registries: Check each for detailed validation rules.
:zap: Overview
isValid*
The isValid*
function returns a boolean if the package name is valid as a package.
isValidNpm('is-valid-package-name') // true
isValidNpm('node_modules') // false
isValidDenoLand('is_valid') // true
isValidDenoLand('is-valid') // false
isValidNestLand('oak') // true
isValidNestLand('o') // false
validate*
The validate*
function returns tuple of boolean and error message.
validateNpm('is-valid-package-name') // [ true, "" ]
validateNpm('node_modules') // [ false, "Name is blacklisted" ]
validateDenoLand('is_valid') // [ true, "" ]
validateDenoLand('is-valid') // [ false, "Name contains only the characters a-z, 0-9 and _" ]
validateNestLand('oak') // [ true, "" ]
validateNestLand('o') // [ false, "Name length must be greater than 1" ]
:dizzy: Usage
is-valid-package-name
provides multi platform modules.
🦕 Deno
deno.land
import { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } from "https://deno.land/x/is_valid_package_name/mod.ts";
nest.land
import { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } from "https://x.nest.land/is_valid_package_name/mod.ts";
:package: Node.js
Install
npm i is-valid-package-name
or
yarn add is-valid-package-name
ES modules
import { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } from "is-valid-package-name";
Commonjs
const { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } = require("is-valid-package-name");
:globe_with_meridians: Browser
The module that bundles the dependencies is obtained from skypack.
<script type="module">
import { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } from "https://cdn.skypack.dev/is-valid-package-name";
</script>
:green_heart: Support
ie is no longer supported to reduce bundle size.
The TypeScript version must be 4.1.0
or higher.
This project provides ES modules
and Commonjs
.
If you have an opinion about what to support, you can open an issue to discuss it.
The browserslist
has the following settings.
defaults
last 8 version
not IE <= 11
not ie_mob <= 11
node 6
| Deno | Node.js | Edge | Firefox | Chrome | Safari | iOS Safari | Samsung | Opera |
| --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| ^1.6.0
| ^6.17.0
| ^83
| ^78
| ^83
| ^11
| ^12.0
| ^7.2
| ^68
|
:handshake: Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues.
:seedling: Show your support
Give a ⭐️ if this project helped you!
:bulb: License
Copyright © 2021-present TomokiMiyauci.
Released under the MIT license