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

    Class VineDate

    VineDate represents a Date object created by parsing a string or number value as a date.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    "[ITYPE]": string | number

    Define the input type of the schema for TypeScript inference

    "[OTYPE]": Date

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

    "[COTYPE]": Date

    Type marker for camelCase output type inference

    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
    }
    rules: {
        equals: (
            ...options: [
                options: { expectedValue: string
                | ((field: FieldContext) => string) } & DateEqualsOptions,
            ],
        ) => Validation<
            { expectedValue: string
            | ((field: FieldContext) => string) } & DateEqualsOptions,
        >;
        after: (
            ...options: [
                options: {
                    expectedValue: | string & { _?: undefined }
                    | "today"
                    | "tomorrow"
                    | ((field: FieldContext) => string);
                } & DateEqualsOptions,
            ],
        ) => Validation<
            {
                expectedValue: | string & { _?: undefined }
                | "today"
                | "tomorrow"
                | ((field: FieldContext) => string);
            } & DateEqualsOptions,
        >;
        afterOrEqual: (
            ...options: [
                options: {
                    expectedValue: | "today"
                    | "tomorrow"
                    | string & { _?: undefined }
                    | ((field: FieldContext) => string);
                } & DateEqualsOptions,
            ],
        ) => Validation<
            {
                expectedValue: | "today"
                | "tomorrow"
                | string & { _?: undefined }
                | ((field: FieldContext) => string);
            } & DateEqualsOptions,
        >;
        before: (
            ...options: [
                options: {
                    expectedValue: | "today"
                    | string & { _?: undefined }
                    | "yesterday"
                    | ((field: FieldContext) => string);
                } & DateEqualsOptions,
            ],
        ) => Validation<
            {
                expectedValue: | "today"
                | string & { _?: undefined }
                | "yesterday"
                | ((field: FieldContext) => string);
            } & DateEqualsOptions,
        >;
        beforeOrEqual: (
            ...options: [
                options: {
                    expectedValue: | "today"
                    | "yesterday"
                    | string & { _?: undefined }
                    | ((field: FieldContext) => string);
                } & DateEqualsOptions,
            ],
        ) => Validation<
            {
                expectedValue: | "today"
                | "yesterday"
                | string & { _?: undefined }
                | ((field: FieldContext) => string);
            } & DateEqualsOptions,
        >;
        sameAs: (
            ...options: [options: { otherField: string } & DateEqualsOptions],
        ) => Validation<{ otherField: string } & DateEqualsOptions>;
        notSameAs: (
            ...options: [options: { otherField: string } & DateEqualsOptions],
        ) => Validation<{ otherField: string } & DateEqualsOptions>;
        afterField: (
            ...options: [options: { otherField: string } & DateEqualsOptions],
        ) => Validation<{ otherField: string } & DateEqualsOptions>;
        afterOrSameAs: (
            ...options: [options: { otherField: string } & DateEqualsOptions],
        ) => Validation<{ otherField: string } & DateEqualsOptions>;
        beforeField: (
            ...options: [options: { otherField: string } & DateEqualsOptions],
        ) => Validation<{ otherField: string } & DateEqualsOptions>;
        beforeOrSameAs: (
            ...options: [options: { otherField: string } & DateEqualsOptions],
        ) => Validation<{ otherField: string } & DateEqualsOptions>;
        weekend: (...options: [options?: undefined]) => Validation<undefined>;
        weekday: (...options: [options?: undefined]) => Validation<undefined>;
    } = ...

    Available VineDate rules

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

    The property must be implemented for "unionOfTypes"

    "[SUBTYPE]": string = 'date'

    The subtype of the literal schema field

    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 }))
    • Enable/disable bail mode for this field. In bail mode, field validations stop after the first error.

      Parameters

      • state: boolean

        Whether to enable bail mode

      Returns VineDate

      This schema instance for method chaining

      vine.string().bail(false) // Continue validation after first error
      vine.number().bail(true) // Stop after first error (default)
    • 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

    • Checks if the value is of date type. The method must be implemented for "unionOfTypes"

      Parameters

      • value: unknown

      Returns boolean

    • The equals rule compares the input value to be same as the expected value.

      By default, the comparions of day, month and years are performed.

      Parameters

      • expectedValue: string | ((field: FieldContext) => string)
      • Optionaloptions: DateEqualsOptions

      Returns this

    • The after rule compares the input value to be after the expected value.

      By default, the comparions of day, month and years are performed.

      Parameters

      • expectedValue:
            | "today"
            | "tomorrow"
            | string & { _?: undefined }
            | ((field: FieldContext) => string)
      • Optionaloptions: DateEqualsOptions

      Returns this

    • The after or equal rule compares the input value to be after or equal to the expected value.

      By default, the comparions of day, month and years are performed.

      Parameters

      • expectedValue:
            | "today"
            | "tomorrow"
            | string & { _?: undefined }
            | ((field: FieldContext) => string)
      • Optionaloptions: DateEqualsOptions

      Returns this

    • The before rule compares the input value to be before the expected value.

      By default, the comparions of day, month and years are performed.

      Parameters

      • expectedValue:
            | "today"
            | "yesterday"
            | string & { _?: undefined }
            | ((field: FieldContext) => string)
      • Optionaloptions: DateEqualsOptions

      Returns this

    • The before rule compares the input value to be before the expected value.

      By default, the comparions of day, month and years are performed.

      Parameters

      • expectedValue:
            | "today"
            | "yesterday"
            | string & { _?: undefined }
            | ((field: FieldContext) => string)
      • Optionaloptions: DateEqualsOptions

      Returns this

    • The sameAs rule expects the input value to be same as the value of the other field.

      By default, the comparions of day, month and years are performed

      Parameters

      Returns this

    • The notSameAs rule expects the input value to be different from the other field's value

      By default, the comparions of day, month and years are performed

      Parameters

      Returns this

    • The afterField rule expects the input value to be after the other field's value.

      By default, the comparions of day, month and years are performed

      Parameters

      Returns this

    • The afterOrSameAs rule expects the input value to be after or equal to the other field's value.

      By default, the comparions of day, month and years are performed

      Parameters

      Returns this

    • The beforeField rule expects the input value to be before the other field's value.

      By default, the comparions of day, month and years are performed

      Parameters

      Returns this

    • The beforeOrSameAs rule expects the input value to be before or same as the other field's value.

      By default, the comparions of day, month and years are performed

      Parameters

      Returns this