-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
the 'fqdn' validator passes the input string to validate through to isFQDN without any extra options
fqdn: (value) => validator.isFQDN(value),
But the isFQDN function supports options such as whether trailing dots are allowed
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/validator/lib/isFQDN.d.ts
export interface IsFQDNOptions {
/**
* @default true
*/
require_tld?: boolean | undefined;
/**
* @default false
*/
allow_underscores?: boolean | undefined;
/**
* @default false
*/
allow_trailing_dot?: boolean | undefined;
/**
* @default false
*/
allow_numeric_tld?: boolean | undefined;
/**
* If `allow_wildcard` is set to true, the validator will allow domain starting with `*.` (e.g. `*.example.com` or `*.shop.example.com`).
* @default false
*/
allow_wildcard?: boolean | undefined;
}
/**
* Check if the string is a fully qualified domain name (e.g. `domain.com`).
*
* @param [options] - Options
*/
export default function isFQDN(str: string, options?: IsFQDNOptions): boolean;This is how I would have liked to use the fqdn library
export type DnsZoneName = VString<['2,128,lowercase', 'fqdn,allow_trailing_dot', 'endsWith,.']>
const FqdnDnsNameVSpec: VSpecOf<DnsZoneName> = ['2,128,lowercase', 'fqdn,allow_trailing_dot', 'endsWith,.']
- But
fqdn,allow_trailing_dotwon't work (as explained) - ...and because 'fqdn' does not allow trailing dots by default,
[... 'fqdn', 'endsWith,.']won't work either.
So I don't have a way to validate that a string is a domain name with non optional trailing dot
I think the fqdn could be made more useful by supporting the optional boolean options in IsFQDNOptions.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels