mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-07 03:56:55 +03:00
25 lines
651 B
TypeScript
25 lines
651 B
TypeScript
import { validateDomain } from './validateDomain';
|
|
import { validateIPV4 } from './validateIp';
|
|
import { ValidationResult } from './types';
|
|
|
|
export function validateDNS(value: string): ValidationResult {
|
|
if (!value) {
|
|
return { valid: false, message: _('DNS server address cannot be empty') };
|
|
}
|
|
|
|
if (validateIPV4(value).valid) {
|
|
return { valid: true, message: _('Valid') };
|
|
}
|
|
|
|
if (validateDomain(value).valid) {
|
|
return { valid: true, message: _('Valid') };
|
|
}
|
|
|
|
return {
|
|
valid: false,
|
|
message: _(
|
|
'Invalid DNS server format. Examples: 8.8.8.8 or dns.example.com or dns.example.com/nicedns for DoH',
|
|
),
|
|
};
|
|
}
|