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

    Class VineObject<Properties, Input, Output, CamelCaseOutput>

    VineObject represents an object value in the validation schema. It validates objects with predefined properties, supports conditional groups, and provides control over unknown properties.

    const schema = vine.object({
    name: vine.string(),
    email: vine.string().email(),
    age: vine.number().min(0)
    })

    const result = await vine.validate({
    schema,
    data: { name: 'John', email: 'john@example.com', age: 30 }
    })

    Type Parameters

    • Properties extends Record<string, SchemaTypes>

      Record of property names to their schema types

    • Input

      The expected input type for this object

    • Output

      The output type after validation and transformation

    • CamelCaseOutput

      The output type with camelCase property names

    Hierarchy (View Summary)

    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

    "[UNIQUE_NAME]": string = 'vine.object'

    Unique name identifier for union type resolution

    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
      })
    • Type checker function to determine if a value is an object. Required for "unionOfTypes" functionality.

      Parameters

      • value: unknown

        The value to check

      Returns boolean

      True if the value is a non-null object and not an array