All Projects → miguelmota → is-valid-domain

miguelmota / is-valid-domain

Licence: MIT License
Validate domain name in JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to is-valid-domain

Hosts Blocklists
Automatically updated, moderated and optimized lists for blocking ads, trackers, malware and other garbage
Stars: ✭ 1,749 (+3398%)
Mutual labels:  domain, hostname
acme-1key
Acme.sh 域名证书一键申请脚本
Stars: ✭ 19 (-62%)
Mutual labels:  domain
svelte-form
JSON Schema form for Svelte v3
Stars: ✭ 47 (-6%)
Mutual labels:  validation
webargs-starlette
Declarative request parsing and validation for Starlette with webargs
Stars: ✭ 36 (-28%)
Mutual labels:  validation
Swiftz-Validation
A data structure for validations. It implements the applicative functor interface
Stars: ✭ 15 (-70%)
Mutual labels:  validation
ttv
A command line tool for splitting files into test, train, and validation sets.
Stars: ✭ 38 (-24%)
Mutual labels:  validation
thai-citizen-id-validator
🦉 Validate Thai Citizen ID with 0 dependencies 🇹🇭
Stars: ✭ 35 (-30%)
Mutual labels:  validation
validada
Another library for defensive data analysis.
Stars: ✭ 29 (-42%)
Mutual labels:  validation
apple-receipt
Apple InAppPurchase Receipt - Models, Parser, Validator
Stars: ✭ 25 (-50%)
Mutual labels:  validation
openapi-schemas
JSON Schemas for every version of the OpenAPI Specification
Stars: ✭ 22 (-56%)
Mutual labels:  validation
xrechnung-schematron
Schematron rules for the German CIUS (XRechnung) of EN16931:2017
Stars: ✭ 19 (-62%)
Mutual labels:  validation
validation
Validation on Laravel 5.X|6.X|7.X|8.X
Stars: ✭ 26 (-48%)
Mutual labels:  validation
fefe
Validate, sanitize and transform values with proper TypeScript types and zero dependencies.
Stars: ✭ 34 (-32%)
Mutual labels:  validation
oolong
oolong 🍵 : create and administrate validation tests for typical automated content analysis tools.
Stars: ✭ 40 (-20%)
Mutual labels:  validation
nexus-validate
🔑 Add argument validation to your GraphQL Nexus API.
Stars: ✭ 29 (-42%)
Mutual labels:  validation
onixcheck
ONIX validation library and commandline tool
Stars: ✭ 20 (-60%)
Mutual labels:  validation
laravel-pwned-passwords
Simple Laravel validation rule that allows you to prevent or limit the re-use of passwords that are known to be pwned (unsafe). Based on TroyHunt's Have I Been Pwned (https://haveibeenpwned.com)
Stars: ✭ 67 (+34%)
Mutual labels:  validation
validator
💯Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
Stars: ✭ 9,721 (+19342%)
Mutual labels:  validation
domainerator
Simple application written in Go that combines two wordlists and a list of TLDs to form domain names and check if they are already registered.
Stars: ✭ 26 (-48%)
Mutual labels:  domain
ruby-magic
Simple interface to libmagic for Ruby Programming Language
Stars: ✭ 23 (-54%)
Mutual labels:  validation

is-valid-domain

Validate domain name in JavaScript

Demo

https://lab.miguelmota.com/is-valid-domain

Install

npm install is-valid-domain

Usage

const isValidDomain = require('is-valid-domain')

isValidDomain('example.com') // true
isValidDomain('foo.example.com') // true
isValidDomain('bar.foo.example.com') // true
isValidDomain('exa-mple.co.uk') // true
isValidDomain('xn--80ak6aa92e.com') // true
isValidDomain('_dnslink.ipfs.io') // true
isValidDomain('exa_mple.com') // false
isValidDomain('-example.co.uk') // false
isValidDomain('example') // false
isValidDomain('ex*mple.com') // false
isValidDomain('*.example.com') // false
isValidDomain('*.com') // false
isValidDomain(3434) // false

isValidDomain('foo.example.com', {subdomain: true}) // true
isValidDomain('foo.example.com', {subdomain: false}) // false
isValidDomain('*.example.com', {wildcard: false}) // false
isValidDomain('*.example.com', {wildcard: true}) // true
isValidDomain('*.example.com', {subdomain: false, wildcard: true}) // false
isValidDomain('はじめよう.みんな') // false
isValidDomain('はじめよう.みんな', {allowUnicode: true}) // true
isValidDomain('ai.') // false
isValidDomain('ai.', {topLevel: true}) // true

view more examples

Test

npm test

Contributing

Adding new domains:

  • Add second level domain to data/second_level_domains.csv
  • Run npm run generate to generate JSON map file
  • Run npm test

FAQ

  • Q: Why is trailing dot . in domain names verified as true?

    • A: Fully qualified domain names allow the trailing dot which represents the root zone. More info here and here.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].