Skip to main content
Glama
schemas.ts•886 B
import { z } from 'zod'; /** * A flexible Zod schema for validating ISO 8601 date-time strings. * * This schema accepts any string that can be successfully parsed by the `Date` constructor, * which includes formats with 'Z' (UTC) and timezone offsets (e.g., '+01:00'). * It refines a base string schema, providing a more specific error message if the * date-time string is invalid. */ export const flexibleDateTimeSchema = z.string().refine((value) => { // Try to parse the date string. // The Date constructor is quite flexible with ISO 8601 formats. const date = new Date(value); // Check if the parsed date is valid. // `isNaN(date.getTime())` is a reliable way to check for invalid dates. return !isNaN(date.getTime()); }, { // Custom error message for invalid date-time strings. message: "Invalid date-time string. Please use a valid ISO 8601 format.", });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aiconnect-cloud/agentjobs-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server