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

    Class BaseType<Input, Output, CamelCaseOutput>Abstract

    The BaseType class abstracts the repetitive parts of creating a custom schema type. It provides common functionality like validation chaining, optional/nullable modifiers, and compilation logic.

    class CustomStringType extends BaseType<string, string, string> {
    [PARSE](propertyName: string, refs: RefsStore, options: ParserOptions) {
    return { type: 'literal', name: propertyName, ... }
    }
    clone() { return new CustomStringType() }
    }

    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

    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 with.

      Parameters

      • callback: ParseFn

        Parser function to transform the input value

      Returns this

      This schema instance for method chaining

      vine.string().parse((value) => {
      return typeof value === 'string' ? value.trim() : value
      })