@nhtio/validation 0.1.0-master-952eca46 → 0.1.0-master-b4207fd6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +85585 -84041
- package/index.cjs.map +1 -1
- package/index.d.mts +13349 -0
- package/index.mjs +85599 -84051
- package/index.mjs.map +1 -1
- package/package.json +5 -3
- package/index.d.ts +0 -36
- package/private/core/errors.d.ts +0 -4
- package/private/core/manifest.d.ts +0 -1
- package/private/core/root.d.ts +0 -56
- package/private/guards.d.ts +0 -67
- package/private/index.d.ts +0 -245
- package/private/libs/knex/client.d.ts +0 -62
- package/private/libs/knex/index.d.ts +0 -10
- package/private/libs/knex/logger.d.ts +0 -15
- package/private/libs/knex/make_knex.d.ts +0 -2
- package/private/libs/knex/transaction.d.ts +0 -37
- package/private/patches/fqdn.d.ts +0 -5
- package/private/patches/i18n.d.ts +0 -51
- package/private/patches/index.d.ts +0 -3
- package/private/patches/json.d.ts +0 -2
- package/private/patches/knex.d.ts +0 -16
- package/private/schemas/bigint.d.ts +0 -95
- package/private/schemas/datetime.d.ts +0 -654
- package/private/schemas/phone.d.ts +0 -199
- package/private/schemas.d.ts +0 -840
- package/private/types.d.ts +0 -69
- package/private/utils.d.ts +0 -186
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nhtio/validation",
|
|
3
|
-
"version": "0.1.0-master-
|
|
3
|
+
"version": "0.1.0-master-b4207fd6",
|
|
4
4
|
"description": "A powerful schema description language and data validator",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Jak Giveon <jak@nht.io>",
|
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
"sqlite3"
|
|
26
26
|
]
|
|
27
27
|
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@nhtio/encoder": "^1.20251201.0"
|
|
30
|
+
},
|
|
28
31
|
"packageManager": "pnpm@10.8.0+sha512.0e82714d1b5b43c74610193cb20734897c1d00de89d0e18420aebc5977fa13d780a9cb05734624e81ebd81cc876cd464794850641c48b9544326b5622ca29971",
|
|
29
|
-
"type": "module"
|
|
30
|
-
"dependencies": {}
|
|
32
|
+
"type": "module"
|
|
31
33
|
}
|
package/index.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import './private/core/errors';
|
|
2
|
-
/**
|
|
3
|
-
* A powerful schema description language and data validator
|
|
4
|
-
* @module @nhtio/validation
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* The current version of the package.
|
|
8
|
-
*
|
|
9
|
-
* @tip This is a constant that is replaced during the build process with the actual version of the package.
|
|
10
|
-
*/
|
|
11
|
-
export declare const version: string;
|
|
12
|
-
export * from './private';
|
|
13
|
-
/**
|
|
14
|
-
* Validate email address and domain.
|
|
15
|
-
* A local version of the `@hapi/address` package used to ensure matching versions.
|
|
16
|
-
*/
|
|
17
|
-
export * as address from '@hapi/address';
|
|
18
|
-
/**
|
|
19
|
-
* Math and string formula parser.
|
|
20
|
-
* A local version of the `@hapi/formula` package used to ensure matching versions.
|
|
21
|
-
*/
|
|
22
|
-
export * as formula from '@hapi/formula';
|
|
23
|
-
/**
|
|
24
|
-
* Return the filename and line number of the calling function.
|
|
25
|
-
* A local version of the `@hapi/pinpoint` package is used to ensure matching versions.
|
|
26
|
-
*/
|
|
27
|
-
export { location } from '@hapi/pinpoint';
|
|
28
|
-
/**
|
|
29
|
-
* TLDS list for domain validation.
|
|
30
|
-
* A local version of the `@hapi/tlds` package is used to ensure matching versions.
|
|
31
|
-
*/
|
|
32
|
-
export { tlds } from '@hapi/tlds';
|
|
33
|
-
export { ValidationError } from 'joi';
|
|
34
|
-
export type { Types, BasicType, LanguageMessages, PresenceMode, ErrorFormattingOptions, BaseValidationOptions, ValidationOptions, AsyncValidationOptions, LanguageMessageTemplate, ErrorValidationOptions, RenameOptions, TopLevelDomainOptions, HierarchySeparatorOptions, DependencyOptions, EmailOptions, DomainOptions, HexOptions, IpOptions, GuidVersions, GuidOptions, UriOptions, DataUriOptions, Base64Options, SwitchCases, SwitchDefault, WhenOptions, WhenSchemaOptions, Cache, CacheProvisionOptions, CacheConfiguration, CompileOptions, IsSchemaOptions, ReferenceOptions, StringRegexOptions, RuleOptions, ErrorReport, ValidationErrorItem, ValidationErrorFunction, ValidationWarning, ValidationResult, CreateErrorOptions, ModifyOptions, MutateRegisterOptions, SetFlagOptions, CustomHelpers, CustomValidator, ExternalHelpers, ExternalValidationFunction, NullableType, IsPrimitiveSubset, IsUnion, IsNonPrimitiveSubsetUnion, SchemaFunction, AddRuleOptions, GetRuleOptions, SchemaInternals, Description, Context, State, ArraySortOptions, ArrayUniqueOptions, ComparatorFunction, ObjectPatternOptions, ExtensionBoundSchema, RuleArgs, RuleMethod, ExtensionRule, CoerceResult, CoerceFunction, CoerceObject, ExtensionFlag, ExtensionTermManifest, ExtensionTerm, Extension, ExtensionFactory, Err, Root, } from 'joi';
|
|
35
|
-
export type { SchemaLikeWithoutArray, SchemaLike, ObjectPropertiesSchema, PartialSchemaMap, StrictSchemaMap, SchemaMap, Schema, } from './private/schemas';
|
|
36
|
-
export type { Country, CountryOrUnknown, PhoneTypes } from '@nhtio/phone-object';
|
package/private/core/errors.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/private/core/root.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { Root } from 'joi';
|
|
2
|
-
import type { Schema } from '../index';
|
|
3
|
-
export type SchemaTypeDefinition = Schema;
|
|
4
|
-
export type SchemaTypeDefinititionMiddlewareFn = (ctx: SchemaTypeDefinition, root: Root, args: any[]) => SchemaTypeDefinition;
|
|
5
|
-
export type ShortcutsMiddlewareFn = (ctx: string[]) => string[];
|
|
6
|
-
export interface RootFactoryOptions {
|
|
7
|
-
schemaTypeModifiers?: SchemaTypeDefinititionMiddlewareFn[];
|
|
8
|
-
shortcutsModifiers?: ShortcutsMiddlewareFn[];
|
|
9
|
-
}
|
|
10
|
-
export declare class RootFactory {
|
|
11
|
-
static readonly $_cachedDescriptions: WeakMap<Schema, any>;
|
|
12
|
-
static readonly types: {
|
|
13
|
-
alternatives: any;
|
|
14
|
-
any: any;
|
|
15
|
-
array: any;
|
|
16
|
-
boolean: any;
|
|
17
|
-
date: any;
|
|
18
|
-
function: any;
|
|
19
|
-
link: any;
|
|
20
|
-
number: any;
|
|
21
|
-
object: any;
|
|
22
|
-
string: any;
|
|
23
|
-
symbol: any;
|
|
24
|
-
binary: any;
|
|
25
|
-
};
|
|
26
|
-
static readonly aliases: {
|
|
27
|
-
alt: string;
|
|
28
|
-
bool: string;
|
|
29
|
-
func: string;
|
|
30
|
-
};
|
|
31
|
-
static assertValue(value: any, schema: any, annotate: boolean, args: any[]): any;
|
|
32
|
-
static generate(root: any, schema: any, args: any[]): any;
|
|
33
|
-
static expandExtension(extension: any, joi: any): any[];
|
|
34
|
-
static getMethods(): {
|
|
35
|
-
ValidationError: any;
|
|
36
|
-
version: any;
|
|
37
|
-
cache: any;
|
|
38
|
-
assert(value: any, schema: any, ...args: any[]): void;
|
|
39
|
-
attempt(value: any, schema: any, ...args: any[]): any;
|
|
40
|
-
build(this: Root, desc: any): any;
|
|
41
|
-
checkPreferences(prefs: any): void;
|
|
42
|
-
compile(this: Root, schema: any, options: any): any;
|
|
43
|
-
defaults(this: Root, modifier: any): Root;
|
|
44
|
-
expression(...args: any[]): any;
|
|
45
|
-
extend(this: Root, ...extensions: any[]): Root;
|
|
46
|
-
isError: any;
|
|
47
|
-
isExpression: any;
|
|
48
|
-
isRef: any;
|
|
49
|
-
isSchema: any;
|
|
50
|
-
in(...args: any[]): any;
|
|
51
|
-
override: any;
|
|
52
|
-
ref(...args: any[]): any;
|
|
53
|
-
types(this: any): any;
|
|
54
|
-
};
|
|
55
|
-
static create(options?: RootFactoryOptions): Root;
|
|
56
|
-
}
|
package/private/guards.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { DateTime } from 'luxon';
|
|
2
|
-
import type { DateObjectUnits } from 'luxon';
|
|
3
|
-
/**
|
|
4
|
-
* Checks if a value is an instance of a specific class.
|
|
5
|
-
* @param value - The value to check
|
|
6
|
-
* @param type - The name of the class to check against
|
|
7
|
-
* @returns true if the value is an instance of the specified class, false otherwise
|
|
8
|
-
*/
|
|
9
|
-
export declare const isInstanceOf: <T>(value: unknown, type: string, ctor?: new (...args: any[]) => T) => value is T;
|
|
10
|
-
/**
|
|
11
|
-
* Type guard to check if a value is a Luxon DateTime instance
|
|
12
|
-
* @param value - The value to check
|
|
13
|
-
* @returns True if the value is a Luxon DateTime, false otherwise
|
|
14
|
-
*/
|
|
15
|
-
export declare const isLuxonDateTime: (value: unknown) => value is DateTime;
|
|
16
|
-
/**
|
|
17
|
-
* Type guard to check if a value is a plain object (not null, not array)
|
|
18
|
-
* @param value - The value to check
|
|
19
|
-
* @returns True if the value is a plain object, false otherwise
|
|
20
|
-
*/
|
|
21
|
-
export declare const isPlainObject: (value: unknown) => value is {
|
|
22
|
-
[key: string]: unknown;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Type guard to check if a value is an array
|
|
26
|
-
* @param value - The value to check
|
|
27
|
-
* @returns True if the value is an array, false otherwise
|
|
28
|
-
*/
|
|
29
|
-
export declare const isArray: (value: unknown) => value is unknown[];
|
|
30
|
-
/**
|
|
31
|
-
* Type guard to check if a value is a valid Luxon DateObjectUnits object.
|
|
32
|
-
*
|
|
33
|
-
* This function validates that the input is a plain object containing only valid
|
|
34
|
-
* Luxon date/time unit properties with numeric values. It ensures type safety
|
|
35
|
-
* when working with objects that should represent date/time units for Luxon operations.
|
|
36
|
-
*
|
|
37
|
-
* @param value - The value to check for DateObjectUnits compatibility
|
|
38
|
-
* @returns True if the value is a valid DateObjectUnits object, false otherwise
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```typescript
|
|
42
|
-
* // Valid DateObjectUnits objects
|
|
43
|
-
* const validUnits1 = { year: 2023, month: 12, day: 25 };
|
|
44
|
-
* const validUnits2 = { hour: 14, minute: 30, second: 45 };
|
|
45
|
-
* const validUnits3 = { weekYear: 2023, weekNumber: 52 };
|
|
46
|
-
*
|
|
47
|
-
* console.log(isDateObjectUnits(validUnits1)); // true
|
|
48
|
-
* console.log(isDateObjectUnits(validUnits2)); // true
|
|
49
|
-
* console.log(isDateObjectUnits(validUnits3)); // true
|
|
50
|
-
*
|
|
51
|
-
* // Invalid cases
|
|
52
|
-
* console.log(isDateObjectUnits({})); // false (empty object)
|
|
53
|
-
* console.log(isDateObjectUnits({ year: "2023" })); // false (string value)
|
|
54
|
-
* console.log(isDateObjectUnits({ invalid: 123 })); // false (invalid property)
|
|
55
|
-
* console.log(isDateObjectUnits(null)); // false
|
|
56
|
-
* console.log(isDateObjectUnits([])); // false
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* @remarks
|
|
60
|
-
* The function validates against all supported Luxon DateObjectUnits properties:
|
|
61
|
-
* - Time units: year, month, day, ordinal
|
|
62
|
-
* - Week-based units: weekYear, localWeekYear, weekNumber, localWeekNumber, weekday, localWeekday
|
|
63
|
-
* - Time of day units: hour, minute, second, millisecond
|
|
64
|
-
*
|
|
65
|
-
* All property values must be numbers or undefined. The object must contain at least one property.
|
|
66
|
-
*/
|
|
67
|
-
export declare const isDateObjectUnits: (value: unknown) => value is DateObjectUnits;
|
package/private/index.d.ts
DELETED
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import type { DateTime } from 'luxon';
|
|
2
|
-
import type { PhoneSchema } from './schemas/phone';
|
|
3
|
-
import type { BigIntSchema } from './schemas/bigint';
|
|
4
|
-
import type { DatetimeSchema } from './schemas/datetime';
|
|
5
|
-
import type { CountryOrUnknown } from '@nhtio/phone-object';
|
|
6
|
-
import type { I18nCallback, SetI18nCallback } from './patches/i18n';
|
|
7
|
-
import type { ValidationOptions, Root, Reference as JoiReference, SchemaMap, SchemaLike, WhenSchemaOptions, WhenOptions, State, ReferenceOptions } from 'joi';
|
|
8
|
-
import type { AnySchema, StringSchema, BinarySchema, NumberSchema, BooleanSchema, ObjectSchema, ArraySchema, DateSchema, AlternativesSchema, FunctionSchema, LinkSchema, SymbolSchema, Schema } from './schemas';
|
|
9
|
-
export type Reference = JoiReference & {
|
|
10
|
-
resolve: (value: any, state: State, prefs: ValidationOptions, local?: any, options?: ReferenceOptions) => any;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Extended Joi root interface that includes custom schema types for
|
|
14
|
-
* additional validation scenarios.
|
|
15
|
-
*
|
|
16
|
-
* This interface extends the standard Joi Root interface to include
|
|
17
|
-
* additional schema types
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* import { validator } from '@nhtio/validation'
|
|
22
|
-
*
|
|
23
|
-
* const schema = validator.object({
|
|
24
|
-
* id: validator.bigint().positive().required(),
|
|
25
|
-
* balance: validator.bigint().min(0n).optional()
|
|
26
|
-
* })
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
export interface ValidationRoot extends Omit<Root, 'allow' | 'alt' | 'alternatives' | 'any' | 'array' | 'binary' | 'bool' | 'boolean' | 'date' | 'disallow' | 'equal' | 'exist' | 'forbidden' | 'func' | 'function' | 'invalid' | 'link' | 'not' | 'number' | 'object' | 'optional' | 'preferences' | 'prefs' | 'required' | 'string' | 'symbol' | 'types' | 'valid' | 'when' | 'ref'> {
|
|
32
|
-
/**
|
|
33
|
-
* Generates a schema object that matches any data type.
|
|
34
|
-
*/
|
|
35
|
-
any<TSchema = any>(): AnySchema<TSchema>;
|
|
36
|
-
/**
|
|
37
|
-
* Generates a schema object that matches an array data type.
|
|
38
|
-
*/
|
|
39
|
-
array<TSchema = any[]>(): ArraySchema<TSchema>;
|
|
40
|
-
/**
|
|
41
|
-
* Generates a schema object that matches a boolean data type (as well as the strings 'true', 'false', 'yes', and 'no'). Can also be called via boolean().
|
|
42
|
-
*/
|
|
43
|
-
bool<TSchema = boolean>(): BooleanSchema<TSchema>;
|
|
44
|
-
/**
|
|
45
|
-
* Generates a schema object that matches a boolean data type (as well as the strings 'true', 'false', 'yes', and 'no'). Can also be called via bool().
|
|
46
|
-
*/
|
|
47
|
-
boolean<TSchema = boolean>(): BooleanSchema<TSchema>;
|
|
48
|
-
/**
|
|
49
|
-
* Generates a schema object that matches a Buffer data type (as well as the strings which will be converted to Buffers).
|
|
50
|
-
*/
|
|
51
|
-
binary<TSchema = Buffer>(): BinarySchema<TSchema>;
|
|
52
|
-
/**
|
|
53
|
-
* Generates a schema object that matches a date type (as well as a JavaScript date string or number of milliseconds).
|
|
54
|
-
*/
|
|
55
|
-
date<TSchema = Date>(): DateSchema<TSchema>;
|
|
56
|
-
/**
|
|
57
|
-
* Generates a schema object that matches a function type.
|
|
58
|
-
*/
|
|
59
|
-
func<TSchema = Function>(): FunctionSchema<TSchema>;
|
|
60
|
-
/**
|
|
61
|
-
* Generates a schema object that matches a function type.
|
|
62
|
-
*/
|
|
63
|
-
function<TSchema = Function>(): FunctionSchema<TSchema>;
|
|
64
|
-
/**
|
|
65
|
-
* Generates a schema object that matches a number data type (as well as strings that can be converted to numbers).
|
|
66
|
-
*/
|
|
67
|
-
number<TSchema = number>(): NumberSchema<TSchema>;
|
|
68
|
-
/**
|
|
69
|
-
* Generates a schema object that matches an object data type (as well as JSON strings that have been parsed into objects).
|
|
70
|
-
*/
|
|
71
|
-
object<TSchema = any, IsStrict = false, T = TSchema>(schema?: SchemaMap<T, IsStrict>): ObjectSchema<TSchema>;
|
|
72
|
-
/**
|
|
73
|
-
* Generates a schema object that matches a string data type. Note that empty strings are not allowed by default and must be enabled with allow('').
|
|
74
|
-
*/
|
|
75
|
-
string<TSchema = string>(): StringSchema<TSchema>;
|
|
76
|
-
/**
|
|
77
|
-
* Generates a schema object that matches any symbol.
|
|
78
|
-
*/
|
|
79
|
-
symbol<TSchema = Symbol>(): SymbolSchema<TSchema>;
|
|
80
|
-
/**
|
|
81
|
-
* Generates a type that will match one of the provided alternative schemas
|
|
82
|
-
*/
|
|
83
|
-
alternatives<TSchema = any>(types: SchemaLike[]): AlternativesSchema<TSchema>;
|
|
84
|
-
alternatives<TSchema = any>(...types: SchemaLike[]): AlternativesSchema<TSchema>;
|
|
85
|
-
/**
|
|
86
|
-
* Alias for `alternatives`
|
|
87
|
-
*/
|
|
88
|
-
alt<TSchema = any>(types: SchemaLike[]): AlternativesSchema<TSchema>;
|
|
89
|
-
alt<TSchema = any>(...types: SchemaLike[]): AlternativesSchema<TSchema>;
|
|
90
|
-
/**
|
|
91
|
-
* Links to another schema node and reuses it for validation, typically for creative recursive schemas.
|
|
92
|
-
*
|
|
93
|
-
* @param ref - the reference to the linked schema node.
|
|
94
|
-
* Cannot reference itself or its children as well as other links.
|
|
95
|
-
* Links can be expressed in relative terms like value references (`Joi.link('...')`),
|
|
96
|
-
* in absolute terms from the schema run-time root (`Joi.link('/a')`),
|
|
97
|
-
* or using schema ids implicitly using object keys or explicitly using `any.id()` (`Joi.link('#a.b.c')`).
|
|
98
|
-
*/
|
|
99
|
-
link<TSchema = any>(ref?: string): LinkSchema<TSchema>;
|
|
100
|
-
/**
|
|
101
|
-
* Generates a schema object that matches a BigInt data type.
|
|
102
|
-
*/
|
|
103
|
-
bigint<TSchema = bigint>(): BigIntSchema<TSchema>;
|
|
104
|
-
/**
|
|
105
|
-
* Generates a schema object that matches a DateTime data type.
|
|
106
|
-
*/
|
|
107
|
-
datetime<TSchema = DateTime>(): DatetimeSchema<TSchema>;
|
|
108
|
-
/**
|
|
109
|
-
* Generates a schema object that matches a phone number data type.
|
|
110
|
-
*
|
|
111
|
-
* @param country - Optional country code or reference for phone validation
|
|
112
|
-
*/
|
|
113
|
-
phone<TSchema = string>(country?: CountryOrUnknown | Reference | null): PhoneSchema<TSchema>;
|
|
114
|
-
/**
|
|
115
|
-
* Returns an object where each key is a plain joi schema type.
|
|
116
|
-
* Useful for creating type shortcuts using deconstruction.
|
|
117
|
-
* Note that the types are already formed and do not need to be called as functions (e.g. `string`, not `string()`).
|
|
118
|
-
*/
|
|
119
|
-
types(): {
|
|
120
|
-
alternatives: AlternativesSchema;
|
|
121
|
-
any: AnySchema;
|
|
122
|
-
array: ArraySchema;
|
|
123
|
-
binary: BinarySchema;
|
|
124
|
-
boolean: BooleanSchema;
|
|
125
|
-
date: DateSchema;
|
|
126
|
-
function: FunctionSchema;
|
|
127
|
-
link: LinkSchema;
|
|
128
|
-
number: NumberSchema;
|
|
129
|
-
object: ObjectSchema;
|
|
130
|
-
string: StringSchema;
|
|
131
|
-
symbol: SymbolSchema;
|
|
132
|
-
bigint: BigIntSchema;
|
|
133
|
-
datetime: DatetimeSchema;
|
|
134
|
-
phone: PhoneSchema;
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Whitelists a value
|
|
138
|
-
*/
|
|
139
|
-
allow(...values: any[]): Schema;
|
|
140
|
-
/**
|
|
141
|
-
* Adds the provided values into the allowed whitelist and marks them as the only valid values allowed.
|
|
142
|
-
*/
|
|
143
|
-
valid(...values: any[]): Schema;
|
|
144
|
-
equal(...values: any[]): Schema;
|
|
145
|
-
/**
|
|
146
|
-
* Blacklists a value
|
|
147
|
-
*/
|
|
148
|
-
invalid(...values: any[]): Schema;
|
|
149
|
-
disallow(...values: any[]): Schema;
|
|
150
|
-
not(...values: any[]): Schema;
|
|
151
|
-
/**
|
|
152
|
-
* Marks a key as required which will not allow undefined as value. All keys are optional by default.
|
|
153
|
-
*/
|
|
154
|
-
required(): Schema;
|
|
155
|
-
/**
|
|
156
|
-
* Alias of `required`.
|
|
157
|
-
*/
|
|
158
|
-
exist(): Schema;
|
|
159
|
-
/**
|
|
160
|
-
* Marks a key as optional which will allow undefined as values. Used to annotate the schema for readability as all keys are optional by default.
|
|
161
|
-
*/
|
|
162
|
-
optional(): Schema;
|
|
163
|
-
/**
|
|
164
|
-
* Marks a key as forbidden which will not allow any value except undefined. Used to explicitly forbid keys.
|
|
165
|
-
*/
|
|
166
|
-
forbidden(): Schema;
|
|
167
|
-
/**
|
|
168
|
-
* Overrides the global validate() options for the current key and any sub-key.
|
|
169
|
-
*/
|
|
170
|
-
preferences(options: ValidationOptions): Schema;
|
|
171
|
-
/**
|
|
172
|
-
* Overrides the global validate() options for the current key and any sub-key.
|
|
173
|
-
*/
|
|
174
|
-
prefs(options: ValidationOptions): Schema;
|
|
175
|
-
/**
|
|
176
|
-
* Converts the type into an alternatives type where the conditions are merged into the type definition where:
|
|
177
|
-
*/
|
|
178
|
-
when(ref: string | Reference, options: WhenOptions | WhenOptions[]): AlternativesSchema;
|
|
179
|
-
when(ref: Schema, options: WhenSchemaOptions): AlternativesSchema;
|
|
180
|
-
/**
|
|
181
|
-
* Creates a reference to another schema key.
|
|
182
|
-
*/
|
|
183
|
-
ref(key: string, options?: ReferenceOptions): Reference;
|
|
184
|
-
/**
|
|
185
|
-
* Sets a global internationalization callback that applies to all validator instances.
|
|
186
|
-
*
|
|
187
|
-
* This method sets a fallback translation function that will be used by the `$i18n` method
|
|
188
|
-
* when no instance-specific callback has been set via `$setI18n`. Once `$setI18n` is called
|
|
189
|
-
* on an instance, that instance will use its own callback instead of the global one.
|
|
190
|
-
*
|
|
191
|
-
* The global callback provides a convenient way to set default translations across your
|
|
192
|
-
* entire application while still allowing individual validator instances to override
|
|
193
|
-
* with their own translations when needed.
|
|
194
|
-
*
|
|
195
|
-
* @param callback - The I18nCallback function that will handle global message translation
|
|
196
|
-
* @returns The validator instance for chaining
|
|
197
|
-
*
|
|
198
|
-
* @example
|
|
199
|
-
* ```typescript
|
|
200
|
-
* // Set up global Spanish translations
|
|
201
|
-
* validator.$setGlobalI18n((term: string) => {
|
|
202
|
-
* return spanishTranslations[term] || term
|
|
203
|
-
* })
|
|
204
|
-
*
|
|
205
|
-
* // All validators will now use Spanish by default
|
|
206
|
-
* const schema1 = validator.string().min(5)
|
|
207
|
-
* const schema2 = validator.number().positive()
|
|
208
|
-
*
|
|
209
|
-
* // But you can still override for specific instances
|
|
210
|
-
* const germanSchema = validator.string().$setI18n(germanCallback)
|
|
211
|
-
* ```
|
|
212
|
-
*/
|
|
213
|
-
$setI18n: SetI18nCallback<ValidationRoot>;
|
|
214
|
-
/**
|
|
215
|
-
* Clears the global internationalization callback.
|
|
216
|
-
*
|
|
217
|
-
* This method removes any previously set global i18n callback, causing the `$i18n` method
|
|
218
|
-
* to fall back to default English messages for validator instances that haven't had their
|
|
219
|
-
* own callback set via `$setI18n`.
|
|
220
|
-
*
|
|
221
|
-
* This is useful for testing scenarios, dynamic language switching, or memory cleanup
|
|
222
|
-
* when you no longer need global translations.
|
|
223
|
-
*
|
|
224
|
-
* @returns The validator instance for chaining
|
|
225
|
-
*
|
|
226
|
-
* @example
|
|
227
|
-
* ```typescript
|
|
228
|
-
* // Set up global translations
|
|
229
|
-
* validator.$setGlobalI18n(spanishCallback)
|
|
230
|
-
*
|
|
231
|
-
* // Later, clear them to return to default English
|
|
232
|
-
* validator.$clearGlobalI18n()
|
|
233
|
-
*
|
|
234
|
-
* // Now all validators use default English messages again
|
|
235
|
-
* const schema = validator.string().min(5) // Uses English messages
|
|
236
|
-
* ```
|
|
237
|
-
*/
|
|
238
|
-
$clearI18n: () => ValidationRoot;
|
|
239
|
-
$i18n: I18nCallback;
|
|
240
|
-
}
|
|
241
|
-
export declare const validator: ValidationRoot;
|
|
242
|
-
export type { BigIntSchema, DatetimeSchema, PhoneSchema, SetI18nCallback, I18nCallback };
|
|
243
|
-
export type * from './schemas';
|
|
244
|
-
export { encode, decode } from './utils';
|
|
245
|
-
export type { Knex } from 'knex';
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'node:events';
|
|
2
|
-
import type { Knex } from 'knex';
|
|
3
|
-
declare class Client extends EventEmitter implements Knex.Client {
|
|
4
|
-
config: any;
|
|
5
|
-
logger: any;
|
|
6
|
-
version?: string;
|
|
7
|
-
connectionConfigProvider?: any;
|
|
8
|
-
connectionConfigExpirationChecker?: any;
|
|
9
|
-
connectionSettings: any;
|
|
10
|
-
driver?: any;
|
|
11
|
-
pool?: any;
|
|
12
|
-
valueForUndefined: any;
|
|
13
|
-
dialect?: string;
|
|
14
|
-
driverName?: string;
|
|
15
|
-
constructor(config?: any);
|
|
16
|
-
formatter(builder: any): any;
|
|
17
|
-
queryBuilder(): any;
|
|
18
|
-
transaction(container: any, config: any, outerTx: any): any;
|
|
19
|
-
queryCompiler(builder: any, formatter: any): any;
|
|
20
|
-
schemaBuilder(): any;
|
|
21
|
-
schemaCompiler(builder: any): any;
|
|
22
|
-
tableBuilder(type: any, tableName: any, tableNameLike: any, fn: any): any;
|
|
23
|
-
viewBuilder(type: any, viewBuilder: any, fn: any): any;
|
|
24
|
-
tableCompiler(tableBuilder: any): any;
|
|
25
|
-
viewCompiler(viewCompiler: any): any;
|
|
26
|
-
columnBuilder(tableBuilder: any, type: any, args: any): any;
|
|
27
|
-
columnCompiler(tableBuilder: any, columnBuilder: any): any;
|
|
28
|
-
runner(builder: any): any;
|
|
29
|
-
raw(): any;
|
|
30
|
-
ref(): any;
|
|
31
|
-
query(connection: any, queryParam: any): any;
|
|
32
|
-
stream(connection: any, queryParam: any, stream: any, options: any): any;
|
|
33
|
-
prepBindings(bindings: any): any;
|
|
34
|
-
positionBindings(sql: any): any;
|
|
35
|
-
postProcessResponse(resp: any, queryContext: any): any;
|
|
36
|
-
wrapIdentifier(value: any, queryContext: any): any;
|
|
37
|
-
customWrapIdentifier(value: any, origImpl: any, queryContext: any): any;
|
|
38
|
-
wrapIdentifierImpl(value: any): string;
|
|
39
|
-
initializeDriver(): void;
|
|
40
|
-
poolDefaults(): {
|
|
41
|
-
min: number;
|
|
42
|
-
max: number;
|
|
43
|
-
propagateCreateError: boolean;
|
|
44
|
-
};
|
|
45
|
-
getPoolSettings(poolConfig: any): any;
|
|
46
|
-
initializePool(config?: any): void;
|
|
47
|
-
validateConnection(_connection: any): boolean;
|
|
48
|
-
acquireConnection(): Promise<any>;
|
|
49
|
-
releaseConnection(connection: any): Promise<void>;
|
|
50
|
-
destroy(callback?: any): Promise<any>;
|
|
51
|
-
database(): any;
|
|
52
|
-
toString(): string;
|
|
53
|
-
assertCanCancelQuery(): void;
|
|
54
|
-
cancelQuery(): void;
|
|
55
|
-
alias(first: any, second: any): string;
|
|
56
|
-
parameter(value: any, builder: any, bindingsHolder: any): any;
|
|
57
|
-
parameterize(values: any, notSetValue: any, builder: any, bindingsHolder: any): any;
|
|
58
|
-
values(values: any, builder: any, bindingsHolder: any): any;
|
|
59
|
-
processPassedConnection(_connection: any): void;
|
|
60
|
-
toPathForJson(jsonPath: any): any;
|
|
61
|
-
}
|
|
62
|
-
export { Client };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Knex } from 'knex';
|
|
2
|
-
export declare function knex(config?: Knex.Config, ...additional: any[]): Knex;
|
|
3
|
-
export declare namespace knex {
|
|
4
|
-
var Client: typeof import("./client").Client;
|
|
5
|
-
var KnexTimeoutError: any;
|
|
6
|
-
var QueryBuilder: {
|
|
7
|
-
extend: (methodName: string, fn: Function) => void;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export { knex as knexInit };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
declare class Logger {
|
|
2
|
-
_inspectionDepth: number;
|
|
3
|
-
_enableColors: boolean;
|
|
4
|
-
_debug: (msg: any) => void;
|
|
5
|
-
_warn: (msg: any) => void;
|
|
6
|
-
_error: (msg: any) => void;
|
|
7
|
-
_deprecate: (msg: any) => void;
|
|
8
|
-
constructor(config?: any);
|
|
9
|
-
_log(message: any, userFn: (msg: any) => void, colorFn?: (msg: string) => string): void;
|
|
10
|
-
debug(message: any): void;
|
|
11
|
-
warn(message: any): void;
|
|
12
|
-
error(message: any): void;
|
|
13
|
-
deprecate(method: string, alternative: string): void;
|
|
14
|
-
}
|
|
15
|
-
export default Logger;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'node:events';
|
|
2
|
-
import type { Knex } from 'knex';
|
|
3
|
-
declare class Transaction extends EventEmitter implements Knex.Transaction<any, any> {
|
|
4
|
-
userParams: any;
|
|
5
|
-
doNotRejectOnRollback: any;
|
|
6
|
-
txid: any;
|
|
7
|
-
client: any;
|
|
8
|
-
logger: any;
|
|
9
|
-
outerTx: any;
|
|
10
|
-
trxClient: any;
|
|
11
|
-
_completed: any;
|
|
12
|
-
_debug: any;
|
|
13
|
-
readOnly: any;
|
|
14
|
-
isolationLevel: any;
|
|
15
|
-
_lastChild: any;
|
|
16
|
-
_promise: any;
|
|
17
|
-
_resolver: any;
|
|
18
|
-
_rejecter: any;
|
|
19
|
-
transactor: any;
|
|
20
|
-
constructor(client: any, container: any, config?: any, outerTx?: any);
|
|
21
|
-
isCompleted(): any;
|
|
22
|
-
begin(conn: any): any;
|
|
23
|
-
savepoint(conn: any): any;
|
|
24
|
-
commit(conn: any, value: any): any;
|
|
25
|
-
release(conn: any, value: any): any;
|
|
26
|
-
setIsolationLevel(isolationLevel: any): this;
|
|
27
|
-
rollback(conn: any, error: any): any;
|
|
28
|
-
rollbackTo(conn: any, error: any): any;
|
|
29
|
-
query(conn: any, sql: any, status?: any, value?: any): any;
|
|
30
|
-
debug(enabled?: any): this;
|
|
31
|
-
_evaluateContainer(config: any, container: any): Promise<any>;
|
|
32
|
-
acquireConnection(config: any, cb: any): Promise<any>;
|
|
33
|
-
then(onResolve?: any, onReject?: any): any;
|
|
34
|
-
catch(...args: any[]): any;
|
|
35
|
-
asCallback(cb: any): any;
|
|
36
|
-
}
|
|
37
|
-
export default Transaction;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { Root } from 'joi';
|
|
2
|
-
/**
|
|
3
|
-
* Callback function type for internationalization translation.
|
|
4
|
-
*
|
|
5
|
-
* This function is responsible for translating validation message keys into
|
|
6
|
-
* localized strings. It receives a message term (like 'string.min') and should
|
|
7
|
-
* return the translated message in the appropriate language.
|
|
8
|
-
*
|
|
9
|
-
* @param term - The message key to translate (e.g., 'string.base', 'number.min')
|
|
10
|
-
* @returns The translated message string, or the original term if translation fails
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const translateToSpanish: I18nCallback = (term: string) => {
|
|
15
|
-
* const translations = {
|
|
16
|
-
* 'string.base': 'debe ser una cadena de texto',
|
|
17
|
-
* 'number.min': 'debe ser mayor o igual a {{#limit}}'
|
|
18
|
-
* }
|
|
19
|
-
* return translations[term] || term
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export interface I18nCallback {
|
|
24
|
-
(term: string): string;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Callback function type for setting up internationalization.
|
|
28
|
-
*
|
|
29
|
-
* This function is used to configure the i18n system by providing a translation
|
|
30
|
-
* callback. Once called, it sets up the root validator instance to use the
|
|
31
|
-
* provided translation function for all validation messages.
|
|
32
|
-
*
|
|
33
|
-
* @param callback - The I18nCallback function that will handle message translation
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* // Set up Spanish translations
|
|
38
|
-
* validator.$setI18n((term: string) => {
|
|
39
|
-
* return spanishTranslations[term] || term
|
|
40
|
-
* })
|
|
41
|
-
*
|
|
42
|
-
* // Set up with external i18n library
|
|
43
|
-
* validator.$setI18n((term: string) => {
|
|
44
|
-
* return i18next.t(`validation.${term}`, { defaultValue: term })
|
|
45
|
-
* })
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export interface SetI18nCallback<T = Root> {
|
|
49
|
-
(this: T, callback: I18nCallback): T;
|
|
50
|
-
}
|
|
51
|
-
export declare const i18n: (toPatch: Root) => Root;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Knex } from 'knex';
|
|
2
|
-
import type { SchemaTypeDefinititionMiddlewareFn } from '../core/root';
|
|
3
|
-
import type { KnexSchemaConnection } from '../schemas';
|
|
4
|
-
export declare const knexMessages: {
|
|
5
|
-
'knex.unique': string;
|
|
6
|
-
'knex.exists': string;
|
|
7
|
-
'knex.missingConnection': string;
|
|
8
|
-
'knex.invalidTable': string;
|
|
9
|
-
'knex.invalidColumn': string;
|
|
10
|
-
'knex.internal': string;
|
|
11
|
-
};
|
|
12
|
-
export declare const resolveQueryBuilder: (connection: KnexSchemaConnection, table: string) => {
|
|
13
|
-
client: Knex;
|
|
14
|
-
query: Knex.QueryBuilder;
|
|
15
|
-
};
|
|
16
|
-
export declare const knex: SchemaTypeDefinititionMiddlewareFn;
|