Overview
Check if the domain name is fully qualified (e.g. domain.com).
Import
import {validators} from 'metronic-extension';
const {isFQDN} = validators;
Signature
isFQDN(value: string, options?: IsFQDNOptions): boolean
| Parameter |
Type |
Default |
Description |
value |
string |
- |
Value to be validated. |
options.requireFQDNTld |
boolean |
true |
If true, the TLD is required. |
options.allowFQDNWildcard |
boolean |
false |
If true, allows domain starting with *. (e.g. *.example.com). |
Returns: boolean — true if valid, false otherwise.
Example
<div class="mb-3">
<label class="form-label">Input value</label>
<input id="isFQDNInput" class="form-control form-control-solid" placeholder="Enter a domain name...">
</div>
<div>
<span class="fw-bold">Result: </span>
<span id="isFQDNResult" class="badge"></span>
</div>
import {validators} from 'metronic-extension';
const {isFQDN} = validators;
isFQDN('example.com'); // true
isFQDN('sub.domain.com'); // true
// Without requiring TLD
isFQDN('localhost', {requireFQDNTld: false}); // true
// Allow wildcard domains
isFQDN('*.example.com', {allowFQDNWildcard: true}); // true
isFQDN('*.shop.example.com', {allowFQDNWildcard: true}); // true