@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
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import type { AnySchema } from '../../index';
|
|
2
|
-
import type { CountryOrUnknown, PhoneTypes } from '@nhtio/phone-object';
|
|
3
|
-
import type { ExtensionFactory, Reference } from 'joi';
|
|
4
|
-
/**
|
|
5
|
-
* Phone number validation schema interface extending AnySchema.
|
|
6
|
-
* Provides methods for validating and formatting phone numbers with various constraints.
|
|
7
|
-
*
|
|
8
|
-
* @template TSchema - The schema type, defaults to string
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import Joi from 'joi'
|
|
13
|
-
* import { phone } from './phone'
|
|
14
|
-
*
|
|
15
|
-
* const extended = Joi.extend(phone)
|
|
16
|
-
* const schema = extended.phone().country('US').mobile()
|
|
17
|
-
*
|
|
18
|
-
* const result = schema.validate('+1234567890')
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export interface PhoneSchema<TSchema = string> extends Omit<AnySchema<TSchema>, 'cast'> {
|
|
22
|
-
/**
|
|
23
|
-
* Sets the country context for phone number validation.
|
|
24
|
-
*
|
|
25
|
-
* @param country - Country code (ISO 3166-1 alpha-2), country name, Joi reference, or null
|
|
26
|
-
* @returns The schema instance for chaining
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* schema.country('US')
|
|
31
|
-
* schema.country('United States')
|
|
32
|
-
* schema.country(Joi.ref('countryField'))
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
country(country: CountryOrUnknown | Reference | null): this;
|
|
36
|
-
/**
|
|
37
|
-
* Sets the output format for the phone number.
|
|
38
|
-
*
|
|
39
|
-
* @param as - The desired output format
|
|
40
|
-
* @returns The schema instance for chaining
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```typescript
|
|
44
|
-
* schema.format('international') // +1 234 567 8900
|
|
45
|
-
* schema.format('national') // (234) 567-8900
|
|
46
|
-
* schema.format('e164') // +12345678900
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
format(as: 'e164' | 'international' | 'national' | 'raw' | 'timezone' | 'type' | 'country'): this;
|
|
50
|
-
/**
|
|
51
|
-
* Validates that the phone number is a fixed line or fixed line/mobile number.
|
|
52
|
-
*
|
|
53
|
-
* @returns The schema instance for chaining
|
|
54
|
-
*/
|
|
55
|
-
fixedLine(): this;
|
|
56
|
-
/**
|
|
57
|
-
* Validates that the phone number is a mobile or fixed line/mobile number.
|
|
58
|
-
*
|
|
59
|
-
* @returns The schema instance for chaining
|
|
60
|
-
*/
|
|
61
|
-
mobile(): this;
|
|
62
|
-
/**
|
|
63
|
-
* Validates that the phone number is strictly a fixed line number only.
|
|
64
|
-
*
|
|
65
|
-
* @returns The schema instance for chaining
|
|
66
|
-
*/
|
|
67
|
-
strictFixedLine(): this;
|
|
68
|
-
/**
|
|
69
|
-
* Validates that the phone number is strictly a mobile number only.
|
|
70
|
-
*
|
|
71
|
-
* @returns The schema instance for chaining
|
|
72
|
-
*/
|
|
73
|
-
strictMobile(): this;
|
|
74
|
-
/**
|
|
75
|
-
* Validates that the phone number is either a fixed line or mobile number.
|
|
76
|
-
*
|
|
77
|
-
* @returns The schema instance for chaining
|
|
78
|
-
*/
|
|
79
|
-
fixedLineOrMobile(): this;
|
|
80
|
-
/**
|
|
81
|
-
* Validates that the phone number is a toll-free number.
|
|
82
|
-
*
|
|
83
|
-
* @returns The schema instance for chaining
|
|
84
|
-
*/
|
|
85
|
-
tollFree(): this;
|
|
86
|
-
/**
|
|
87
|
-
* Validates that the phone number is a premium rate number.
|
|
88
|
-
*
|
|
89
|
-
* @returns The schema instance for chaining
|
|
90
|
-
*/
|
|
91
|
-
premiumRate(): this;
|
|
92
|
-
/**
|
|
93
|
-
* Validates that the phone number is a shared cost number.
|
|
94
|
-
*
|
|
95
|
-
* @returns The schema instance for chaining
|
|
96
|
-
*/
|
|
97
|
-
sharedCost(): this;
|
|
98
|
-
/**
|
|
99
|
-
* Validates that the phone number is a VoIP number.
|
|
100
|
-
*
|
|
101
|
-
* @returns The schema instance for chaining
|
|
102
|
-
*/
|
|
103
|
-
voip(): this;
|
|
104
|
-
/**
|
|
105
|
-
* Validates that the phone number is a personal number.
|
|
106
|
-
*
|
|
107
|
-
* @returns The schema instance for chaining
|
|
108
|
-
*/
|
|
109
|
-
personalNumber(): this;
|
|
110
|
-
/**
|
|
111
|
-
* Validates that the phone number is a pager number.
|
|
112
|
-
*
|
|
113
|
-
* @returns The schema instance for chaining
|
|
114
|
-
*/
|
|
115
|
-
pager(): this;
|
|
116
|
-
/**
|
|
117
|
-
* Validates that the phone number is a UAN (Universal Access Number).
|
|
118
|
-
*
|
|
119
|
-
* @returns The schema instance for chaining
|
|
120
|
-
*/
|
|
121
|
-
uan(): this;
|
|
122
|
-
/**
|
|
123
|
-
* Validates that the phone number is a voicemail number.
|
|
124
|
-
*
|
|
125
|
-
* @returns The schema instance for chaining
|
|
126
|
-
*/
|
|
127
|
-
voicemail(): this;
|
|
128
|
-
/**
|
|
129
|
-
* Validates that the phone number is of unknown type.
|
|
130
|
-
*
|
|
131
|
-
* @returns The schema instance for chaining
|
|
132
|
-
*/
|
|
133
|
-
unknown(): this;
|
|
134
|
-
/**
|
|
135
|
-
* Validates that the phone number matches one of the specified types.
|
|
136
|
-
*
|
|
137
|
-
* @param types - Array of phone types to allow
|
|
138
|
-
* @returns The schema instance for chaining
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```typescript
|
|
142
|
-
* schema.types('MOBILE', 'FIXED_LINE')
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
|
-
types(...types: PhoneTypes[]): this;
|
|
146
|
-
cast(to: 'number' | 'string' | 'object'): this;
|
|
147
|
-
}
|
|
148
|
-
export declare const messages: {
|
|
149
|
-
'phone.base': string;
|
|
150
|
-
'phone.invalid': string;
|
|
151
|
-
'phone.fixedLine': string;
|
|
152
|
-
'phone.mobile': string;
|
|
153
|
-
'phone.strictFixedLine': string;
|
|
154
|
-
'phone.strictMobile': string;
|
|
155
|
-
'phone.fixedLineOrMobile': string;
|
|
156
|
-
'phone.tollFree': string;
|
|
157
|
-
'phone.premiumRate': string;
|
|
158
|
-
'phone.sharedCost': string;
|
|
159
|
-
'phone.voip': string;
|
|
160
|
-
'phone.personalNumber': string;
|
|
161
|
-
'phone.pager': string;
|
|
162
|
-
'phone.uan': string;
|
|
163
|
-
'phone.voicemail': string;
|
|
164
|
-
'phone.unknown': string;
|
|
165
|
-
'phone.types': string;
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* Joi extension factory for phone number validation.
|
|
169
|
-
* Creates a custom Joi schema type that validates phone numbers using the @nhtio/phone-object library.
|
|
170
|
-
*
|
|
171
|
-
* @param joi - The Joi instance to extend
|
|
172
|
-
* @returns The phone schema extension definition
|
|
173
|
-
*
|
|
174
|
-
* @example
|
|
175
|
-
* ```typescript
|
|
176
|
-
* import Joi from 'joi'
|
|
177
|
-
* import { phone } from './phone'
|
|
178
|
-
*
|
|
179
|
-
* const extended = Joi.extend(phone)
|
|
180
|
-
*
|
|
181
|
-
* // Basic phone validation
|
|
182
|
-
* const schema = extended.phone()
|
|
183
|
-
* schema.validate('+1234567890') // validates any phone number
|
|
184
|
-
*
|
|
185
|
-
* // Country-specific validation
|
|
186
|
-
* const usSchema = extended.phone().country('US')
|
|
187
|
-
* usSchema.validate('(555) 123-4567')
|
|
188
|
-
*
|
|
189
|
-
* // Type-specific validation
|
|
190
|
-
* const mobileSchema = extended.phone().mobile()
|
|
191
|
-
* mobileSchema.validate('+1234567890')
|
|
192
|
-
*
|
|
193
|
-
* // Format output
|
|
194
|
-
* const formattedSchema = extended.phone().format('international')
|
|
195
|
-
* const result = formattedSchema.validate('+1234567890')
|
|
196
|
-
* // result.value would be "+1 234 567 8900"
|
|
197
|
-
* ```
|
|
198
|
-
*/
|
|
199
|
-
export declare const phone: ExtensionFactory;
|