UNPKG

@conform-to/zod

Version:

Conform helpers for integrating with Zod

26 lines (20 loc) 718 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var constraint = require('./constraint.js'); /** * Type guard to check if a value is a Zod schema. */ function isSchema(schema) { return typeof schema === 'object' && schema !== null && '~standard' in schema && typeof schema['~standard'] === 'object' && schema['~standard'] !== null && 'vendor' in schema['~standard'] && schema['~standard'].vendor === 'zod'; } /** * Extracts HTML validation attributes from a Zod schema. */ function getConstraints(schema) { if (!isSchema(schema)) { return undefined; } return constraint.getZodConstraint(schema); } exports.getConstraints = getConstraints; exports.isSchema = isSchema;