is-valid-package-name
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

logo image

is-valid-package-name

Validation for package name

test GitHub release deno land nest badge deno doc deno version node support version npm download

GitHub (Pre-)Release Date dependencies Status codecov Codacy Badge npm type definitions Commitizen friendly Gitmoji semantic-release License: MIT


A validator collection of package names for each package registry

Features

  • 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.

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" ]

💫 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";

📦 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");

🌐 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>

💚 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
DenoDeno Node.jsNode.js IE / EdgeEdge FirefoxFirefox ChromeChrome SafariSafari iOS SafariiOS Safari SamsungSamsung OperaOpera
^1.6.0 ^6.17.0 ^83 ^78 ^83 ^11 ^12.0 ^7.2 ^68

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues.

🌱 Show your support

Give a ⭐️ if this project helped you!

💡 License

Copyright © 2021-present TomokiMiyauci.

Released under the MIT license

Dependencies (2)

Dev Dependencies (14)

Package Sidebar

Install

npm i is-valid-package-name

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

60.8 kB

Total Files

9

Last publish

Collaborators

  • miyauci