domainSchema (mastra/contracts.ts)

mastra · templates/template-lead-qualification/src/mastra/contracts.ts · typescript · Apache-2.0
crm

Validates domain, email, and lead data structures for lead qualification systems.

// Source: https://github.com/mastra-ai/mastra | License: Apache-2.0 | Copyright 2025 Kepler Software, Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { isIP } from 'node:net';
import { domainToASCII } from 'node:url';
import { z } from 'zod';

const reference = z
  .string()
  .min(1)
  .max(200)
  .regex(/^[a-zA-Z0-9][a-zA-Z0-9._:@-]*$/);
const timestamp = z.iso.datetime({ offset: true });

export const domainSchema = z
  .string()
  .trim()
  .max(253)
  .regex(/^[\p{L}\p{N}\p{M}.-]+$/u, 'Use a hostname without URL syntax')
  .transform(value => domainToASCII(value.toLowerCase().replace(/\.$/, '')))
  .refine(
    value =>
      value.length <= 253 &&
      !isIP(value) &&
      /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+(?:[a-z]{2,63}|xn--[a-z0-9-]{0,58}[a

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key