Validation for package name
A validator collection of package names for each package registry
- β‘ Multi runtime support (
Deno,Node.js) - π Pure TypeScript and provides type definition
- π¦ Optimized, super slim size
- π TSDoc-style comments
Currently providing validators for the following package registries: Check each for detailed validation rules.
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') // falseThe 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" ]is-valid-package-name provides multi platform modules.
import { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } from "https://deno.land/x/is_valid_package_name/mod.ts";import { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } from "https://x.nest.land/is_valid_package_name/mod.ts";npm i is-valid-package-name
or
yarn add is-valid-package-nameimport { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } from "is-valid-package-name";const { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } = require("is-valid-package-name");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>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 |
Contributions, issues and feature requests are welcome!
Feel free to check issues.
Give a βοΈ if this project helped you!
Copyright Β© 2021-present TomokiMiyauci.
Released under the MIT license







