ip.ts 338 B

1234567891011121314151617
  1. import { z } from "zod";
  2. export const isIP = (value: string): boolean => {
  3. const ip = z.string().ip();
  4. const parsed = ip.safeParse(value);
  5. return parsed.success;
  6. };
  7. export const stringifiedDNSRecordType = (value: string): string => {
  8. if (isIP(value)) {
  9. return "an A record";
  10. } else {
  11. return "a CNAME record";
  12. }
  13. };