Stone.js API
    Preparing search index...

    The contract a schema class exposes.

    One method, rules(), returning what to validate per source. It is deliberately declarative: a contract that describes itself can be read by @stone-js/openapi to publish the request schema, which a method that merely validated could never be.

    The class is resolved by the container, so its constructor receives services and rules() can use them. That is what makes translated messages possible without a second method for them:

    @ValidationSchema('createUser')
    export class CreateUserSchema implements IValidationSchema {
    private readonly i18n: II18n
    constructor ({ i18n }: { i18n: II18n }) { this.i18n = i18n }

    rules () {
    return {
    body: z.object({ email: z.string().email(this.i18n.t('validation.email')) })
    }
    }
    }

    The same class validates a form on the frontend, because nothing here knows about HTTP: resolve it from the container and call rules(), or hand it to the Validator directly. One schema, both sides, which is the whole reason the module is agnostic.

    interface IValidationSchema {
        rules: () => RouteValidationInput;
    }
    Index

    What this schema validates, per source. A bare schema is read as the body.