@vinejs/vine
Advanced tools
Comparing version 2.1.0 to 3.0.0
@@ -5,4 +5,4 @@ import { | ||
helpers | ||
} from "../chunk-2W32DW3L.js"; | ||
import "../chunk-CSAU5B4Q.js"; | ||
} from "../chunk-YXNUTVGP.js"; | ||
import "../chunk-MLKGABMK.js"; | ||
@@ -212,2 +212,1 @@ // factories/field.ts | ||
}; | ||
//# sourceMappingURL=main.js.map |
@@ -21,4 +21,4 @@ import type { FieldContext, Validation } from '../src/types.js'; | ||
rule: string; | ||
index?: number | undefined; | ||
meta?: Record<string, any> | undefined; | ||
index?: number; | ||
meta?: Record<string, any>; | ||
}[]; | ||
@@ -25,0 +25,0 @@ /** |
@@ -7,2 +7,3 @@ import { Vine } from './src/vine/main.js'; | ||
export { VineEnum } from './src/schema/enum/main.js'; | ||
export { VineNativeEnum } from './src/schema/enum/native_enum.js'; | ||
export { VineTuple } from './src/schema/tuple/main.js'; | ||
@@ -9,0 +10,0 @@ export { VineUnion } from './src/schema/union/main.js'; |
@@ -13,2 +13,3 @@ import { | ||
VineLiteral, | ||
VineNativeEnum, | ||
VineNumber, | ||
@@ -23,4 +24,3 @@ VineObject, | ||
vine_default | ||
} from "./chunk-46WINKKP.js"; | ||
import "./chunk-577THMJC.js"; | ||
} from "./chunk-R73PVWGV.js"; | ||
import { | ||
@@ -30,4 +30,5 @@ SimpleErrorReporter, | ||
main_exports | ||
} from "./chunk-2W32DW3L.js"; | ||
import "./chunk-CSAU5B4Q.js"; | ||
} from "./chunk-YXNUTVGP.js"; | ||
import "./chunk-M2DOTJGC.js"; | ||
import "./chunk-MLKGABMK.js"; | ||
export { | ||
@@ -47,2 +48,3 @@ BaseLiteralType, | ||
VineLiteral, | ||
VineNativeEnum, | ||
VineNumber, | ||
@@ -59,2 +61,1 @@ VineObject, | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -33,2 +33,3 @@ /** | ||
uuid: string; | ||
ulid: string; | ||
hexCode: string; | ||
@@ -35,0 +36,0 @@ boolean: string; |
import { | ||
fields, | ||
messages | ||
} from "../chunk-577THMJC.js"; | ||
import "../chunk-CSAU5B4Q.js"; | ||
} from "../chunk-M2DOTJGC.js"; | ||
import "../chunk-MLKGABMK.js"; | ||
export { | ||
@@ -10,2 +10,1 @@ fields, | ||
}; | ||
//# sourceMappingURL=defaults.js.map |
import { BaseLiteralType } from '../base/literal.js'; | ||
import type { FieldOptions, Validation } from '../../types.js'; | ||
import { SUBTYPE } from '../../symbols.js'; | ||
/** | ||
@@ -13,2 +14,6 @@ * VineAccepted represents a checkbox input that must be checked | ||
}; | ||
/** | ||
* The subtype of the literal schema field | ||
*/ | ||
[SUBTYPE]: string; | ||
constructor(options?: Partial<FieldOptions>, validations?: Validation<any>[]); | ||
@@ -15,0 +20,0 @@ /** |
import { BaseLiteralType } from '../base/literal.js'; | ||
import type { FieldOptions, Validation } from '../../types.js'; | ||
import { SUBTYPE } from '../../symbols.js'; | ||
/** | ||
@@ -9,2 +10,6 @@ * VineAny represents a value that can be anything | ||
/** | ||
* The subtype of the literal schema field | ||
*/ | ||
[SUBTYPE]: string; | ||
/** | ||
* Clones the VineAny schema type. The applied options | ||
@@ -11,0 +16,0 @@ * and validations are copied to the new instance |
@@ -18,5 +18,5 @@ import { RefsStore, ArrayNode } from '@vinejs/compiler/types'; | ||
distinct: (options: { | ||
fields?: string | string[] | undefined; | ||
fields?: string | string[]; | ||
}) => Validation<{ | ||
fields?: string | string[] | undefined; | ||
fields?: string | string[]; | ||
}>; | ||
@@ -47,3 +47,3 @@ minLength: (options: { | ||
*/ | ||
[IS_OF_TYPE]: (value: unknown) => boolean; | ||
[IS_OF_TYPE]: (value: unknown) => value is any[]; | ||
constructor(schema: Schema, options?: FieldOptions, validations?: Validation<any>[]); | ||
@@ -50,0 +50,0 @@ /** |
@@ -33,5 +33,5 @@ /** | ||
export declare const distinctRule: (options: { | ||
fields?: string | string[] | undefined; | ||
fields?: string | string[]; | ||
}) => import("../../types.js").Validation<{ | ||
fields?: string | string[] | undefined; | ||
fields?: string | string[]; | ||
}>; | ||
@@ -38,0 +38,0 @@ /** |
import Macroable from '@poppinss/macroable'; | ||
import type { LiteralNode, RefsStore } from '@vinejs/compiler/types'; | ||
import { OTYPE, COTYPE, PARSE, ITYPE } from '../../symbols.js'; | ||
import { OTYPE, COTYPE, PARSE, ITYPE, SUBTYPE } from '../../symbols.js'; | ||
import type { Parser, Validation, RuleBuilder, Transformer, FieldContext, FieldOptions, ParserOptions, ConstructableSchema, ComparisonOperators, ArrayComparisonOperators, NumericComparisonOperators } from '../../types.js'; | ||
@@ -13,3 +13,5 @@ /** | ||
*/ | ||
abstract [PARSE](propertyName: string, refs: RefsStore, options: ParserOptions): LiteralNode; | ||
abstract [PARSE](propertyName: string, refs: RefsStore, options: ParserOptions): LiteralNode & { | ||
subtype: string; | ||
}; | ||
/** | ||
@@ -62,3 +64,5 @@ * The child class must implement the clone method | ||
*/ | ||
[PARSE](propertyName: string, refs: RefsStore, options: ParserOptions): LiteralNode; | ||
[PARSE](propertyName: string, refs: RefsStore, options: ParserOptions): LiteralNode & { | ||
subtype: string; | ||
}; | ||
} | ||
@@ -133,3 +137,5 @@ /** | ||
*/ | ||
[PARSE](propertyName: string, refs: RefsStore, options: ParserOptions): LiteralNode; | ||
[PARSE](propertyName: string, refs: RefsStore, options: ParserOptions): LiteralNode & { | ||
subtype: string; | ||
}; | ||
} | ||
@@ -156,3 +162,5 @@ /** | ||
*/ | ||
[PARSE](propertyName: string, refs: RefsStore, options: ParserOptions): LiteralNode; | ||
[PARSE](propertyName: string, refs: RefsStore, options: ParserOptions): LiteralNode & { | ||
subtype: string; | ||
}; | ||
} | ||
@@ -165,2 +173,6 @@ /** | ||
/** | ||
* Specify the subtype of the literal schema field | ||
*/ | ||
abstract [SUBTYPE]: string; | ||
/** | ||
* The child class must implement the clone method | ||
@@ -214,4 +226,6 @@ */ | ||
*/ | ||
[PARSE](propertyName: string, refs: RefsStore, options: ParserOptions): LiteralNode; | ||
[PARSE](propertyName: string, refs: RefsStore, options: ParserOptions): LiteralNode & { | ||
subtype: string; | ||
}; | ||
} | ||
export {}; |
@@ -1,4 +0,4 @@ | ||
import type { CompilerNodes, RefsStore } from '@vinejs/compiler/types'; | ||
import type { FieldContext, RefsStore } from '@vinejs/compiler/types'; | ||
import { ITYPE, OTYPE, COTYPE, PARSE } from '../../symbols.js'; | ||
import type { Parser, Validation, RuleBuilder, FieldOptions, ParserOptions, ConstructableSchema } from '../../types.js'; | ||
import type { Parser, Validation, RuleBuilder, FieldOptions, CompilerNodes, ParserOptions, ConstructableSchema, ComparisonOperators, ArrayComparisonOperators, NumericComparisonOperators } from '../../types.js'; | ||
import Macroable from '@poppinss/macroable'; | ||
@@ -63,4 +63,58 @@ /** | ||
#private; | ||
constructor(parent: Schema); | ||
/** | ||
* Optional modifier validations list | ||
*/ | ||
validations: Validation<any>[]; | ||
constructor(parent: Schema, validations?: Validation<any>[]); | ||
/** | ||
* Shallow clones the validations. Since, there are no API's to mutate | ||
* the validation options, we can safely copy them by reference. | ||
*/ | ||
protected cloneValidations(): Validation<any>[]; | ||
/** | ||
* Compiles validations | ||
*/ | ||
protected compileValidations(refs: RefsStore): { | ||
ruleFnId: `ref://${number}`; | ||
implicit: boolean; | ||
isAsync: boolean; | ||
}[]; | ||
/** | ||
* Push a validation to the validations chain. | ||
*/ | ||
use(validation: Validation<any> | RuleBuilder): this; | ||
/** | ||
* Define a callback to conditionally require a field at | ||
* runtime. | ||
* | ||
* The callback method should return "true" to mark the | ||
* field as required, or "false" to skip the required | ||
* validation | ||
*/ | ||
requiredWhen<Operator extends ComparisonOperators>(otherField: string, operator: Operator, expectedValue: Operator extends ArrayComparisonOperators ? (string | number | boolean)[] : Operator extends NumericComparisonOperators ? number : string | number | boolean): this; | ||
requiredWhen(callback: (field: FieldContext) => boolean): this; | ||
/** | ||
* Mark the field under validation as required when all | ||
* the other fields are present with value other | ||
* than `undefined` or `null`. | ||
*/ | ||
requiredIfExists(fields: string | string[]): this; | ||
/** | ||
* Mark the field under validation as required when any | ||
* one of the other fields are present with non-nullable | ||
* value. | ||
*/ | ||
requiredIfAnyExists(fields: string[]): this; | ||
/** | ||
* Mark the field under validation as required when all | ||
* the other fields are missing or their value is | ||
* `undefined` or `null`. | ||
*/ | ||
requiredIfMissing(fields: string | string[]): this; | ||
/** | ||
* Mark the field under validation as required when any | ||
* one of the other fields are missing. | ||
*/ | ||
requiredIfAnyMissing(fields: string[]): this; | ||
/** | ||
* Creates a fresh instance of the underlying schema type | ||
@@ -67,0 +121,0 @@ * and wraps it inside the optional modifier |
import { BaseLiteralType } from '../base/literal.js'; | ||
import { IS_OF_TYPE, UNIQUE_NAME } from '../../symbols.js'; | ||
import { IS_OF_TYPE, SUBTYPE, UNIQUE_NAME } from '../../symbols.js'; | ||
import type { FieldOptions, Validation } from '../../types.js'; | ||
@@ -13,5 +13,5 @@ /** | ||
boolean: (options: { | ||
strict?: boolean | undefined; | ||
strict?: boolean; | ||
}) => Validation<{ | ||
strict?: boolean | undefined; | ||
strict?: boolean; | ||
}>; | ||
@@ -23,2 +23,6 @@ }; | ||
/** | ||
* The subtype of the literal schema field | ||
*/ | ||
[SUBTYPE]: string; | ||
/** | ||
* The property must be implemented for "unionOfTypes" | ||
@@ -25,0 +29,0 @@ */ |
@@ -5,5 +5,5 @@ /** | ||
export declare const booleanRule: (options: { | ||
strict?: boolean | undefined; | ||
strict?: boolean; | ||
}) => import("../../types.js").Validation<{ | ||
strict?: boolean | undefined; | ||
strict?: boolean; | ||
}>; |
@@ -20,3 +20,3 @@ import Macroable from '@poppinss/macroable'; | ||
import { ITYPE, OTYPE, COTYPE } from '../symbols.js'; | ||
import type { DateFieldOptions, EnumLike, FieldContext, SchemaTypes } from '../types.js'; | ||
import type { UndefinedOptional, DateFieldOptions, EnumLike, FieldContext, SchemaTypes } from '../types.js'; | ||
/** | ||
@@ -68,3 +68,3 @@ * Schema builder exposes methods to construct a Vine schema. You may | ||
*/ | ||
object<Properties extends Record<string, SchemaTypes>>(properties: Properties): VineObject<Properties, { [K in keyof Properties]: Properties[K][typeof ITYPE]; }, { [K_1 in keyof Properties]: Properties[K_1][typeof OTYPE]; }, { [K_2 in keyof Properties as CamelCase<K_2 & string>]: Properties[K_2][typeof COTYPE]; }>; | ||
object<Properties extends Record<string, SchemaTypes>>(properties: Properties): VineObject<Properties, UndefinedOptional<{ [K in keyof Properties]: Properties[K][typeof ITYPE]; }>, UndefinedOptional<{ [K_1 in keyof Properties]: Properties[K_1][typeof OTYPE]; }>, UndefinedOptional<{ [K_2 in keyof Properties as CamelCase<K_2 & string>]: Properties[K_2][typeof COTYPE]; }>>; | ||
/** | ||
@@ -71,0 +71,0 @@ * Define an array field and validate its children elements. |
import { BaseLiteralType } from '../base/literal.js'; | ||
import { IS_OF_TYPE, UNIQUE_NAME } from '../../symbols.js'; | ||
import { IS_OF_TYPE, SUBTYPE, UNIQUE_NAME } from '../../symbols.js'; | ||
import type { Validation, FieldOptions, FieldContext, DateFieldOptions, DateEqualsOptions } from '../../types.js'; | ||
@@ -19,35 +19,35 @@ /** | ||
after: (options: { | ||
expectedValue: (string & { | ||
_?: undefined; | ||
}) | "today" | "tomorrow" | ((field: FieldContext) => string); | ||
expectedValue: "today" | "tomorrow" | (string & { | ||
_?: never; | ||
}) | ((field: FieldContext) => string); | ||
} & DateEqualsOptions) => Validation<{ | ||
expectedValue: (string & { | ||
_?: undefined; | ||
}) | "today" | "tomorrow" | ((field: FieldContext) => string); | ||
expectedValue: "today" | "tomorrow" | (string & { | ||
_?: never; | ||
}) | ((field: FieldContext) => string); | ||
} & DateEqualsOptions>; | ||
afterOrEqual: (options: { | ||
expectedValue: "today" | "tomorrow" | (string & { | ||
_?: undefined; | ||
_?: never; | ||
}) | ((field: FieldContext) => string); | ||
} & DateEqualsOptions) => Validation<{ | ||
expectedValue: "today" | "tomorrow" | (string & { | ||
_?: undefined; | ||
_?: never; | ||
}) | ((field: FieldContext) => string); | ||
} & DateEqualsOptions>; | ||
before: (options: { | ||
expectedValue: "today" | (string & { | ||
_?: undefined; | ||
}) | "yesterday" | ((field: FieldContext) => string); | ||
expectedValue: "today" | "yesterday" | (string & { | ||
_?: never; | ||
}) | ((field: FieldContext) => string); | ||
} & DateEqualsOptions) => Validation<{ | ||
expectedValue: "today" | (string & { | ||
_?: undefined; | ||
}) | "yesterday" | ((field: FieldContext) => string); | ||
expectedValue: "today" | "yesterday" | (string & { | ||
_?: never; | ||
}) | ((field: FieldContext) => string); | ||
} & DateEqualsOptions>; | ||
beforeOrEqual: (options: { | ||
expectedValue: "today" | "yesterday" | (string & { | ||
_?: undefined; | ||
_?: never; | ||
}) | ((field: FieldContext) => string); | ||
} & DateEqualsOptions) => Validation<{ | ||
expectedValue: "today" | "yesterday" | (string & { | ||
_?: undefined; | ||
_?: never; | ||
}) | ((field: FieldContext) => string); | ||
@@ -93,2 +93,6 @@ } & DateEqualsOptions>; | ||
/** | ||
* The subtype of the literal schema field | ||
*/ | ||
[SUBTYPE]: string; | ||
/** | ||
* Checks if the value is of date type. The method must be | ||
@@ -95,0 +99,0 @@ * implemented for "unionOfTypes" |
@@ -26,7 +26,7 @@ import type { DateEqualsOptions, DateFieldOptions, FieldContext } from '../../types.js'; | ||
export declare const afterRule: (options: { | ||
expectedValue: 'today' | 'tomorrow' | (string & { | ||
expectedValue: "today" | "tomorrow" | (string & { | ||
_?: never; | ||
}) | ((field: FieldContext) => string); | ||
} & DateEqualsOptions) => import("../../types.js").Validation<{ | ||
expectedValue: 'today' | 'tomorrow' | (string & { | ||
expectedValue: "today" | "tomorrow" | (string & { | ||
_?: never; | ||
@@ -42,7 +42,7 @@ }) | ((field: FieldContext) => string); | ||
export declare const afterOrEqualRule: (options: { | ||
expectedValue: 'today' | 'tomorrow' | (string & { | ||
expectedValue: "today" | "tomorrow" | (string & { | ||
_?: never; | ||
}) | ((field: FieldContext) => string); | ||
} & DateEqualsOptions) => import("../../types.js").Validation<{ | ||
expectedValue: 'today' | 'tomorrow' | (string & { | ||
expectedValue: "today" | "tomorrow" | (string & { | ||
_?: never; | ||
@@ -58,7 +58,7 @@ }) | ((field: FieldContext) => string); | ||
export declare const beforeRule: (options: { | ||
expectedValue: 'today' | 'yesterday' | (string & { | ||
expectedValue: "today" | "yesterday" | (string & { | ||
_?: never; | ||
}) | ((field: FieldContext) => string); | ||
} & DateEqualsOptions) => import("../../types.js").Validation<{ | ||
expectedValue: 'today' | 'yesterday' | (string & { | ||
expectedValue: "today" | "yesterday" | (string & { | ||
_?: never; | ||
@@ -74,7 +74,7 @@ }) | ((field: FieldContext) => string); | ||
export declare const beforeOrEqualRule: (options: { | ||
expectedValue: 'today' | 'yesterday' | (string & { | ||
expectedValue: "today" | "yesterday" | (string & { | ||
_?: never; | ||
}) | ((field: FieldContext) => string); | ||
} & DateEqualsOptions) => import("../../types.js").Validation<{ | ||
expectedValue: 'today' | 'yesterday' | (string & { | ||
expectedValue: "today" | "yesterday" | (string & { | ||
_?: never; | ||
@@ -81,0 +81,0 @@ }) | ((field: FieldContext) => string); |
import { BaseLiteralType } from '../base/literal.js'; | ||
import type { FieldContext, FieldOptions, Validation } from '../../types.js'; | ||
import { SUBTYPE } from '../../symbols.js'; | ||
/** | ||
@@ -20,2 +21,6 @@ * VineEnum represents a enum data type that performs validation | ||
/** | ||
* The subtype of the literal schema field | ||
*/ | ||
[SUBTYPE]: string; | ||
/** | ||
* Returns the enum choices | ||
@@ -22,0 +27,0 @@ */ |
import { BaseLiteralType } from '../base/literal.js'; | ||
import type { EnumLike, FieldOptions, Validation } from '../../types.js'; | ||
import { SUBTYPE } from '../../symbols.js'; | ||
/** | ||
@@ -22,2 +23,6 @@ * VineNativeEnum represents a enum data type that performs validation | ||
}; | ||
/** | ||
* The subtype of the literal schema field | ||
*/ | ||
[SUBTYPE]: string; | ||
constructor(values: Values, options?: FieldOptions, validations?: Validation<any>[]); | ||
@@ -24,0 +29,0 @@ /** |
import { BaseLiteralType } from '../base/literal.js'; | ||
import type { FieldOptions, Validation } from '../../types.js'; | ||
import { SUBTYPE } from '../../symbols.js'; | ||
/** | ||
@@ -13,11 +14,11 @@ * VineLiteral represents a type that matches an exact value | ||
equals: (options: { | ||
expectedValue: any; /** | ||
* Default collection of literal rules | ||
*/ | ||
expectedValue: any; | ||
}) => Validation<{ | ||
expectedValue: any; /** | ||
* Default collection of literal rules | ||
*/ | ||
expectedValue: any; | ||
}>; | ||
}; | ||
/** | ||
* The subtype of the literal schema field | ||
*/ | ||
[SUBTYPE]: string; | ||
constructor(value: Value, options?: FieldOptions, validations?: Validation<any>[]); | ||
@@ -24,0 +25,0 @@ /** |
import { BaseLiteralType } from '../base/literal.js'; | ||
import { FieldOptions, Validation } from '../../types.js'; | ||
import { IS_OF_TYPE, UNIQUE_NAME } from '../../symbols.js'; | ||
import { IS_OF_TYPE, SUBTYPE, UNIQUE_NAME } from '../../symbols.js'; | ||
/** | ||
@@ -38,10 +38,10 @@ * VineNumber represents a numeric value in the validation schema. | ||
number: (options: { | ||
strict?: boolean | undefined; | ||
strict?: boolean; | ||
}) => Validation<{ | ||
strict?: boolean | undefined; | ||
strict?: boolean; | ||
}>; | ||
decimal: (options: { | ||
range: [number, (number | undefined)?]; | ||
range: [number, number?]; | ||
}) => Validation<{ | ||
range: [number, (number | undefined)?]; | ||
range: [number, number?]; | ||
}>; | ||
@@ -53,2 +53,6 @@ negative: (options?: undefined) => Validation<undefined>; | ||
/** | ||
* The subtype of the literal schema field | ||
*/ | ||
[SUBTYPE]: string; | ||
/** | ||
* The property must be implemented for "unionOfTypes" | ||
@@ -55,0 +59,0 @@ */ |
@@ -6,5 +6,5 @@ /** | ||
export declare const numberRule: (options: { | ||
strict?: boolean | undefined; | ||
strict?: boolean; | ||
}) => import("../../types.js").Validation<{ | ||
strict?: boolean | undefined; | ||
strict?: boolean; | ||
}>; | ||
@@ -11,0 +11,0 @@ /** |
@@ -5,3 +5,3 @@ import { ObjectGroup } from './group.js'; | ||
import { OTYPE, COTYPE, ITYPE } from '../../symbols.js'; | ||
import type { FieldContext, SchemaTypes } from '../../types.js'; | ||
import type { FieldContext, SchemaTypes, UndefinedOptional } from '../../types.js'; | ||
/** | ||
@@ -13,5 +13,5 @@ * Create an object group. Groups are used to conditionally merge properties | ||
export declare namespace group { | ||
var _a: <Properties extends Record<string, SchemaTypes>>(conditon: (value: Record<string, unknown>, field: FieldContext) => any, properties: Properties) => GroupConditional<Properties, { [K in keyof Properties]: Properties[K][typeof ITYPE]; }, { [K_1 in keyof Properties]: Properties[K_1][typeof OTYPE]; }, { [K_2 in keyof Properties as CamelCase<K_2 & string>]: Properties[K_2][typeof COTYPE]; }>; | ||
var _b: <Properties extends Record<string, SchemaTypes>>(properties: Properties) => GroupConditional<Properties, { [K in keyof Properties]: Properties[K][typeof ITYPE]; }, { [K_1 in keyof Properties]: Properties[K_1][typeof OTYPE]; }, { [K_2 in keyof Properties as CamelCase<K_2 & string>]: Properties[K_2][typeof COTYPE]; }>; | ||
var _a: <Properties extends Record<string, SchemaTypes>>(conditon: (value: Record<string, unknown>, field: FieldContext) => any, properties: Properties) => GroupConditional<Properties, UndefinedOptional<{ [K in keyof Properties]: Properties[K][typeof ITYPE]; }>, UndefinedOptional<{ [K_1 in keyof Properties]: Properties[K_1][typeof OTYPE]; }>, UndefinedOptional<{ [K_2 in keyof Properties as CamelCase<K_2 & string>]: Properties[K_2][typeof COTYPE]; }>>; | ||
var _b: <Properties extends Record<string, SchemaTypes>>(properties: Properties) => GroupConditional<Properties, UndefinedOptional<{ [K in keyof Properties]: Properties[K][typeof ITYPE]; }>, UndefinedOptional<{ [K_1 in keyof Properties]: Properties[K_1][typeof OTYPE]; }>, UndefinedOptional<{ [K_2 in keyof Properties as CamelCase<K_2 & string>]: Properties[K_2][typeof COTYPE]; }>>; | ||
export { _a as if, _b as else }; | ||
} |
import { BaseLiteralType } from '../base/literal.js'; | ||
import { IS_OF_TYPE, UNIQUE_NAME } from '../../symbols.js'; | ||
import { IS_OF_TYPE, SUBTYPE, UNIQUE_NAME } from '../../symbols.js'; | ||
import type { Validation, AlphaOptions, FieldContext, FieldOptions, AlphaNumericOptions, NormalizeEmailOptions } from '../../types.js'; | ||
@@ -19,6 +19,7 @@ import { urlRule, uuidRule, emailRule, mobileRule, passportRule, creditCardRule, postalCodeRule, normalizeUrlRule } from './rules.js'; | ||
uuid: (options?: { | ||
version?: (1 | 2 | 3 | 4 | 5)[] | undefined; | ||
version?: (1 | 2 | 3 | 4 | 5)[]; | ||
} | undefined) => Validation<{ | ||
version?: (1 | 2 | 3 | 4 | 5)[] | undefined; | ||
version?: (1 | 2 | 3 | 4 | 5)[]; | ||
} | undefined>; | ||
ulid: (options?: undefined) => Validation<undefined>; | ||
trim: (options?: undefined) => Validation<undefined>; | ||
@@ -75,4 +76,4 @@ email: (options?: import("validator/lib/isEmail.js").IsEmailOptions | undefined) => Validation<import("validator/lib/isEmail.js").IsEmailOptions | undefined>; | ||
} | undefined>; | ||
creditCard: (options?: import("../../types.js").CreditCardOptions | ((field: FieldContext) => void | import("../../types.js").CreditCardOptions | undefined) | undefined) => Validation<import("../../types.js").CreditCardOptions | ((field: FieldContext) => void | import("../../types.js").CreditCardOptions | undefined) | undefined>; | ||
postalCode: (options?: import("../../types.js").PostalCodeOptions | ((field: FieldContext) => void | import("../../types.js").PostalCodeOptions | undefined) | undefined) => Validation<import("../../types.js").PostalCodeOptions | ((field: FieldContext) => void | import("../../types.js").PostalCodeOptions | undefined) | undefined>; | ||
creditCard: (options?: import("../../types.js").CreditCardOptions | ((field: FieldContext) => import("../../types.js").CreditCardOptions | void | undefined) | undefined) => Validation<import("../../types.js").CreditCardOptions | ((field: FieldContext) => import("../../types.js").CreditCardOptions | void | undefined) | undefined>; | ||
postalCode: (options?: import("../../types.js").PostalCodeOptions | ((field: FieldContext) => import("../../types.js").PostalCodeOptions | void | undefined) | undefined) => Validation<import("../../types.js").PostalCodeOptions | ((field: FieldContext) => import("../../types.js").PostalCodeOptions | void | undefined) | undefined>; | ||
startsWith: (options: { | ||
@@ -97,2 +98,6 @@ substring: string; | ||
/** | ||
* The subtype of the literal schema field | ||
*/ | ||
[SUBTYPE]: string; | ||
/** | ||
* The property must be implemented for "unionOfTypes" | ||
@@ -105,3 +110,3 @@ */ | ||
*/ | ||
[IS_OF_TYPE]: (value: unknown) => boolean; | ||
[IS_OF_TYPE]: (value: unknown) => value is string; | ||
constructor(options?: FieldOptions, validations?: Validation<any>[]); | ||
@@ -133,3 +138,3 @@ /** | ||
/** | ||
* Validates the value to be an active URL | ||
* Validates the value against a regular expression | ||
*/ | ||
@@ -234,2 +239,6 @@ regex(expression: RegExp): this; | ||
/** | ||
* Validates the value to be a valid ULID | ||
*/ | ||
ulid(): this; | ||
/** | ||
* Validates the value contains ASCII characters only | ||
@@ -236,0 +245,0 @@ */ |
@@ -172,7 +172,11 @@ import type { FieldContext } from '@vinejs/compiler/types'; | ||
export declare const uuidRule: (options?: { | ||
version?: (1 | 2 | 3 | 4 | 5)[] | undefined; | ||
version?: (1 | 2 | 3 | 4 | 5)[]; | ||
} | undefined) => import("../../types.js").Validation<{ | ||
version?: (1 | 2 | 3 | 4 | 5)[] | undefined; | ||
version?: (1 | 2 | 3 | 4 | 5)[]; | ||
} | undefined>; | ||
/** | ||
* Validates the value to be a valid ULID | ||
*/ | ||
export declare const ulidRule: (options?: undefined) => import("../../types.js").Validation<undefined>; | ||
/** | ||
* Validates the value contains ASCII characters only | ||
@@ -179,0 +183,0 @@ */ |
@@ -19,3 +19,3 @@ import { RefsStore, TupleNode } from '@vinejs/compiler/types'; | ||
*/ | ||
[IS_OF_TYPE]: (value: unknown) => boolean; | ||
[IS_OF_TYPE]: (value: unknown) => value is any[]; | ||
constructor(schemas: [...Schema], options?: FieldOptions, validations?: Validation<any>[]); | ||
@@ -22,0 +22,0 @@ /** |
@@ -30,1 +30,5 @@ /** | ||
export declare const VALIDATION: unique symbol; | ||
/** | ||
* The symbol for the subtype of a literal field | ||
*/ | ||
export declare const SUBTYPE: unique symbol; |
@@ -8,3 +8,3 @@ import type dayjs from 'dayjs'; | ||
import type { IsMobilePhoneOptions, MobilePhoneLocale } from 'validator/lib/isMobilePhone.js'; | ||
import type { ParseFn, RefsStore, TransformFn, FieldContext, CompilerNodes, MessagesProviderContact, ErrorReporterContract as BaseReporter } from '@vinejs/compiler/types'; | ||
import type { ParseFn, RefsStore, TupleNode, ArrayNode, UnionNode, RecordNode, ObjectNode, TransformFn, LiteralNode, FieldContext, MessagesProviderContact, ErrorReporterContract as BaseReporter } from '@vinejs/compiler/types'; | ||
import type { helpers } from './vine/helpers.js'; | ||
@@ -14,2 +14,8 @@ import type { ValidationError } from './errors/validation_error.js'; | ||
/** | ||
* Compiler nodes emitted by Vine | ||
*/ | ||
export type CompilerNodes = (LiteralNode & { | ||
subtype: string; | ||
}) | ObjectNode | ArrayNode | UnionNode | RecordNode | TupleNode; | ||
/** | ||
* Options accepted by the mobile number validation | ||
@@ -228,1 +234,15 @@ */ | ||
export type ComparisonOperators = ArrayComparisonOperators | NumericComparisonOperators | '=' | '!='; | ||
type PickUndefined<T> = { | ||
[K in keyof T]: undefined extends T[K] ? K : never; | ||
}[keyof T]; | ||
type PickNotUndefined<T> = { | ||
[K in keyof T]: undefined extends T[K] ? never : K; | ||
}[keyof T]; | ||
type Id<T> = T extends infer U ? { | ||
[K in keyof U]: U[K]; | ||
} : never; | ||
export type UndefinedOptional<T> = Id<{ | ||
[K in PickUndefined<T>]?: T[K]; | ||
} & { | ||
[K in PickNotUndefined<T>]: T[K]; | ||
}>; |
import isURL from 'validator/lib/isURL.js'; | ||
import isIBAN from 'validator/lib/isIBAN.js'; | ||
import isEmail from 'validator/lib/isEmail.js'; | ||
import { type PostalCodeLocale } from 'validator/lib/isPostalCode.js'; | ||
import { type MobilePhoneLocale } from 'validator/lib/isMobilePhone.js'; | ||
import type { FieldContext } from '../types.js'; | ||
@@ -55,3 +57,3 @@ /** | ||
*/ | ||
isArray<Value_1>(value: unknown): value is Value_1[]; | ||
isArray<Value>(value: unknown): value is Value[]; | ||
/** | ||
@@ -90,6 +92,10 @@ * Check if the value is a number or a string representation of a number. | ||
isDecimal: typeof import("validator").isDecimal; | ||
mobileLocales: import("validator").MobilePhoneLocale[]; | ||
postalCountryCodes: import("validator").PostalCodeLocale[]; | ||
mobileLocales: MobilePhoneLocale[]; | ||
postalCountryCodes: PostalCodeLocale[]; | ||
passportCountryCodes: readonly ["AM", "AR", "AT", "AU", "AZ", "BE", "BG", "BR", "BY", "CA", "CH", "CY", "CZ", "DE", "DK", "DZ", "ES", "FI", "FR", "GB", "GR", "HR", "HU", "IE", "IN", "ID", "IR", "IS", "IT", "JM", "JP", "KR", "KZ", "LI", "LT", "LU", "LV", "LY", "MT", "MZ", "MY", "MX", "NL", "NZ", "PH", "PK", "PL", "PT", "RO", "RU", "SE", "SL", "SK", "TH", "TR", "UA", "US"]; | ||
/** | ||
* Check if the value is a valid ULID | ||
*/ | ||
isULID(value: unknown): boolean; | ||
/** | ||
* Check if the value is a valid color hexcode | ||
@@ -96,0 +102,0 @@ */ |
@@ -33,6 +33,4 @@ import { createRule } from './create_rule.js'; | ||
isObject<Value>(value: unknown): value is Record<PropertyKey, Value>; | ||
hasKeys(value: Record<string, any>, keys: string[]): boolean; /** | ||
* Data to validate | ||
*/ | ||
isArray<Value_1>(value: unknown): value is Value_1[]; | ||
hasKeys(value: Record<string, any>, keys: string[]): boolean; | ||
isArray<Value>(value: unknown): value is Value[]; | ||
isNumeric(value: any): boolean; | ||
@@ -57,8 +55,9 @@ asNumber(value: any): number; | ||
isDecimal: typeof import("validator").isDecimal; | ||
mobileLocales: import("validator").MobilePhoneLocale[]; | ||
postalCountryCodes: import("validator").PostalCodeLocale[]; | ||
mobileLocales: import("validator/lib/isMobilePhone.js").MobilePhoneLocale[]; | ||
postalCountryCodes: import("validator/lib/isPostalCode.js").PostalCodeLocale[]; | ||
passportCountryCodes: readonly ["AM", "AR", "AT", "AU", "AZ", "BE", "BG", "BR", "BY", "CA", "CH", "CY", "CZ", "DE", "DK", "DZ", "ES", "FI", "FR", "GB", "GR", "HR", "HU", "IE", "IN", "ID", "IR", "IS", "IT", "JM", "JP", "KR", "KZ", "LI", "LT", "LU", "LV", "LY", "MT", "MZ", "MY", "MX", "NL", "NZ", "PH", "PK", "PL", "PT", "RO", "RU", "SE", "SL", "SK", "TH", "TR", "UA", "US"]; | ||
isULID(value: unknown): boolean; | ||
isHexColor: (value: string) => boolean; | ||
isActiveURL: (url: string) => Promise<boolean>; | ||
isDistinct: (dataSet: any[], fields?: string | string[] | undefined) => boolean; | ||
isDistinct: (dataSet: any[], fields?: string | string[]) => boolean; | ||
getNestedValue(key: string, field: import("@vinejs/compiler/types").FieldContext): any; | ||
@@ -65,0 +64,0 @@ }; |
141
package.json
{ | ||
"name": "@vinejs/vine", | ||
"description": "Form data validation library for Node.js", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"engines": { | ||
@@ -26,55 +26,51 @@ "node": ">=18.16.0" | ||
"test": "c8 npm run quick:test", | ||
"quick:test": "node --loader=ts-node/esm --enable-source-maps bin/test.ts", | ||
"lint": "eslint", | ||
"format": "prettier --write .", | ||
"typecheck": "tsc --noEmit", | ||
"clean": "del-cli build", | ||
"typecheck": "tsc --noEmit", | ||
"precompile": "npm run lint && npm run clean", | ||
"compile": "tsup-node && tsc --emitDeclarationOnly --declaration", | ||
"build": "npm run compile", | ||
"release": "npx release-it", | ||
"version": "npm run build", | ||
"prepublishOnly": "npm run build", | ||
"lint": "eslint . --ext=.ts", | ||
"format": "prettier --write .", | ||
"release": "npx release-it", | ||
"benchmark": "node build/benchmarks/flat_object.js && node build/benchmarks/nested_object.js && node build/benchmarks/array.js && node build/benchmarks/union.js", | ||
"sync-labels": "github-label-sync --labels .github/labels.json vinejs/vine" | ||
"quick:test": "node --import=ts-node-maintained/register/esm --enable-source-maps bin/test.ts" | ||
}, | ||
"devDependencies": { | ||
"@adonisjs/eslint-config": "^1.3.0", | ||
"@adonisjs/prettier-config": "^1.3.0", | ||
"@adonisjs/tsconfig": "^1.3.0", | ||
"@commitlint/cli": "^19.3.0", | ||
"@commitlint/config-conventional": "^19.2.2", | ||
"@adonisjs/eslint-config": "^2.0.0-beta.7", | ||
"@adonisjs/prettier-config": "^1.4.0", | ||
"@adonisjs/tsconfig": "^1.4.0", | ||
"@japa/assert": "^3.0.0", | ||
"@japa/expect-type": "^2.0.2", | ||
"@japa/runner": "^3.1.4", | ||
"@japa/snapshot": "^2.0.5", | ||
"@swc/core": "^1.5.3", | ||
"@types/dlv": "^1.1.4", | ||
"@types/node": "^20.12.10", | ||
"ajv": "^8.13.0", | ||
"@japa/snapshot": "^2.0.6", | ||
"@release-it/conventional-changelog": "^9.0.3", | ||
"@swc/core": "^1.9.3", | ||
"@types/dlv": "^1.1.5", | ||
"@types/node": "^22.10.1", | ||
"ajv": "^8.17.1", | ||
"benchmark": "^2.1.4", | ||
"c8": "^9.1.0", | ||
"del-cli": "^5.1.0", | ||
"eslint": "^8.57.0", | ||
"github-label-sync": "^2.3.1", | ||
"husky": "^9.0.11", | ||
"joi": "^17.13.1", | ||
"prettier": "^3.2.5", | ||
"release-it": "^17.2.1", | ||
"ts-node": "^10.9.2", | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.4.5", | ||
"valibot": "^0.30.0", | ||
"c8": "^10.1.2", | ||
"del-cli": "^6.0.0", | ||
"eslint": "^9.16.0", | ||
"joi": "^17.13.3", | ||
"prettier": "^3.4.1", | ||
"release-it": "^17.10.0", | ||
"ts-node-maintained": "^10.9.4", | ||
"tsup": "^8.3.5", | ||
"typescript": "^5.7.2", | ||
"valibot": "^0.42.1", | ||
"yup": "^1.4.0", | ||
"zod": "^3.23.7" | ||
"zod": "^3.23.8" | ||
}, | ||
"dependencies": { | ||
"@poppinss/macroable": "^1.0.2", | ||
"@types/validator": "^13.11.9", | ||
"@vinejs/compiler": "^2.5.0", | ||
"@poppinss/macroable": "^1.0.3", | ||
"@types/validator": "^13.12.2", | ||
"@vinejs/compiler": "^3.0.0", | ||
"camelcase": "^8.0.0", | ||
"dayjs": "^1.11.11", | ||
"dayjs": "^1.11.13", | ||
"dlv": "^1.1.3", | ||
"normalize-url": "^8.0.1", | ||
"validator": "^13.11.0" | ||
"validator": "^13.12.0" | ||
}, | ||
@@ -84,2 +80,6 @@ "author": "virk,vinejs", | ||
"homepage": "https://github.com/vinejs/vine#readme", | ||
"keywords": [ | ||
"validator", | ||
"validation" | ||
], | ||
"repository": { | ||
@@ -92,27 +92,46 @@ "type": "git", | ||
}, | ||
"keywords": [], | ||
"types": "./build/index.d.ts", | ||
"eslintConfig": { | ||
"extends": "@adonisjs/eslint-config/package" | ||
}, | ||
"prettier": "@adonisjs/prettier-config", | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"tag": "latest" | ||
"provenance": true | ||
}, | ||
"tsup": { | ||
"entry": [ | ||
"./index.ts", | ||
"./src/defaults.ts", | ||
"./factories/main.ts", | ||
"./src/types.ts", | ||
"./benchmarks/flat_object.ts", | ||
"./benchmarks/nested_object.ts", | ||
"./benchmarks/array.ts", | ||
"./benchmarks/union.ts" | ||
], | ||
"outDir": "./build", | ||
"clean": true, | ||
"format": "esm", | ||
"dts": false, | ||
"sourcemap": false, | ||
"target": "esnext" | ||
}, | ||
"release-it": { | ||
"git": { | ||
"requireCleanWorkingDir": true, | ||
"requireUpstream": true, | ||
"commitMessage": "chore(release): ${version}", | ||
"tagAnnotation": "v${version}", | ||
"push": true, | ||
"tagName": "v${version}" | ||
}, | ||
"github": { | ||
"release": true, | ||
"releaseName": "v${version}", | ||
"web": true | ||
"release": true | ||
}, | ||
"npm": { | ||
"publish": true, | ||
"skipChecks": true | ||
}, | ||
"plugins": { | ||
"@release-it/conventional-changelog": { | ||
"preset": { | ||
"name": "angular" | ||
} | ||
} | ||
} | ||
@@ -132,23 +151,3 @@ }, | ||
}, | ||
"directories": { | ||
"test": "tests" | ||
}, | ||
"tsup": { | ||
"entry": [ | ||
"./index.ts", | ||
"./src/defaults.ts", | ||
"./factories/main.ts", | ||
"./src/types.ts", | ||
"./benchmarks/flat_object.ts", | ||
"./benchmarks/nested_object.ts", | ||
"./benchmarks/array.ts", | ||
"./benchmarks/union.ts" | ||
], | ||
"outDir": "./build", | ||
"clean": true, | ||
"format": "esm", | ||
"dts": false, | ||
"sourcemap": true, | ||
"target": "esnext" | ||
} | ||
"prettier": "@adonisjs/prettier-config" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
25
7076
228407
60
+ Added@vinejs/compiler@3.0.0(transitive)
- Removed@vinejs/compiler@2.5.1(transitive)
Updated@poppinss/macroable@^1.0.3
Updated@types/validator@^13.12.2
Updated@vinejs/compiler@^3.0.0
Updateddayjs@^1.11.13
Updatedvalidator@^13.12.0