@vinejs/vine - v4.0.0-next.1
    Preparing search index...

    Class BaseLiteralType<Input, Output, CamelCaseOutput>Abstract

    The base type for creating a custom literal type. Literal types are schema types that have no children elements, such as strings, numbers, booleans, and dates.

    class CustomLiteralType extends BaseLiteralType<string, string, string> {
    [SUBTYPE] = 'custom'
    clone() { return new CustomLiteralType() }
    }

    Type Parameters

    • Input

      The expected input type for this schema

    • Output

      The output type after validation and transformation

    • CamelCaseOutput

      The output type with camelCase field names

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    "[ITYPE]": Input

    Define the input type of the schema for TypeScript inference

    "[OTYPE]": Output

    The output value type of the field after validation. The property points to a type only and not the real value.

    "[COTYPE]": CamelCaseOutput

    Type marker for camelCase output type inference

    "[SUBTYPE]": string

    Specify the subtype of the literal schema field. This is used by the compiler to identify the schema type.

    dataTypeValidator?: Validation<any>

    The validation to use for validating the schema data type. Using a data type validator guards custom rules to only run when the data type validation passes.

    class StringSchema extends BaseLiteralType {
    dataTypeValidator = stringDataTypeRule
    }

    Methods

    • Define a method to parse the input value. The method is invoked before any validation and hence you must perform type-checking to know the value you are working it.

      Parameters

      • callback: ParseFn

      Returns this

    • Adds a validation rule to the schema's validation chain. Rules are executed in the order they are added.

      Parameters

      Returns this

      This schema instance for method chaining

      vine.string().use(minLength({ length: 3 }))
      vine.number().use(customRule({ strict: true }))
    • Compiles the literal schema type into a compiler node. This method transforms the schema definition into a format that the validation compiler can process.

      Parameters

      • propertyName: string

        Name of the property being compiled

      • refs: RefsStore

        Reference store for the compiler

      • options: ParserOptions

        Parser options including camelCase conversion

      Returns FieldNode & {} & { subtype: string }

      Compiled literal node with subtype information