Skip to main content
Deno 2 is finally here 🎉️
Learn more

Fields

JSON definition of form fields

Validation

validateFields

Validates a field definition

const validateFields: (fields: any) => {
  isValid: boolean;
  messages?: string[];
};

validateValue

Validates a value against a field definition

const validateValue: (field: Field, value: any) => {
  isValid: boolean;
  message?: string;
};

validateValues

Validates an object against an array of field definitions

const validateValues: (fields: Field[], data: any) => {
  isValid: boolean;
  messages?: string[];
};

Convert

toJsonSchema

Convert an array of field definitions to a JSON schema

const toJsonSchema = (fields: Field[]) => JSONSchema7;

toTypeDefinition

Create a typescript interface from an array of field definitions

const toTypeDefinition = (fields: Field[]) => string;