How to validate domain in angular or node javascript

 How to validate domain in angular or node javascript 

___________________________________in Angular___________________________________
first you need to install plugin using this command
npm install is-valid-domain

how to use or integrate plugin in component just need to follow this syntex and then use varible "isValidDomain" method that have serveral parameter

import * as isValidDomain from 'is-valid-domain';

and how to use validation
this.isvalidDomainName()

the defination of validator methord

  isvalidDomainName() {
    return isValidDomain(this.domainForm.get('DomainName').value, { subdomain: true })
  }

_____________________________________in node__________________________________________

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})

For more information just go to its official site
https://www.npmjs.com/package/is-valid-domain





1 comment:

Thank You For Your Great Contribution

Featured Post

How to integrate okta with react / Implementing Okta authentication in a React app

 How to integrate okta with react /  Implementing Okta authentication in a React app for demo please follow  my git repo 1).Before starting ...

Popular Posts