Is Domain Valid
Dependency free domain name syntax validator with TLD checking and IDN support. See below examples to check what the validator checks for:
Valid examples
examplecomsubexamplecom // allowSubdomain options is requriedexa-mplecomxn--c1yn36fcom // allowIdn option is required*wildcardcom // allowWildcard and allowSubdomain options are required
Invalid examples
123123123 // checkTld option is requiredexampleexam_plecom-examplecomexample-comexa--mplecomexampledoesnotexist // checkTld option is requiredxn--c1yn--bbcom*comexample*com
Installation
Install the library with npm --save is-domain-valid
Usage
const isDomainValid = ;const res = ;if resresult console; else console;
Options
Options can be passed as a second argument in isDomainValid
function:
const defaultOptions = checkTld: true allowIdn: true allowSubdomain: true allowWildcard: false;const res = ;
Build and contribution
Push requests are very welcome. Run tests with npm run tests
and then build the library with npm run build
.
Author
Adam Blok: https://github.com/adamblok
License
MIT