Code0 LogoCodeZero

@Schema

Attaches a Zod schema to a DataType class

Attaches a Zod schema to a DataType class. Hercules uses the schema to derive validation rules and the type structure sent to Aquila.

import { Schema } from '@code0-tech/hercules';
import { z } from 'zod';

Signature

@Schema(schema: ZodTypeAny): ClassDecorator

Example

const EmailSchema = z.string().regex(/^[^@]+@[^@]+\.[^@]+$/);

@Identifier('email_address')
@Name({ code: 'en-US', content: 'Email Address' })
@Schema(EmailSchema)
export class EmailDataType {}

Applies to

DataType

On this page