@player-ui/common-types-plugin 0.8.0--canary.307.9621 → 0.8.0-next.0
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/dist/CommonTypesPlugin.native.js +11903 -0
- package/dist/CommonTypesPlugin.native.js.map +1 -0
- package/dist/{index.cjs.js → cjs/index.cjs} +273 -233
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/{index.esm.js → index.legacy-esm.js} +246 -220
- package/dist/index.mjs +782 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +26 -58
- package/src/__tests__/index.test.ts +198 -0
- package/src/data-types/types.ts +27 -37
- package/src/formats/__tests__/formats.test.ts +264 -0
- package/src/formats/__tests__/utils.test.ts +44 -0
- package/src/formats/index.ts +71 -69
- package/src/formats/utils.ts +16 -16
- package/src/index.ts +12 -12
- package/src/validators/__tests__/index.test.ts +472 -0
- package/src/validators/index.ts +67 -68
- package/types/data-types/types.d.ts +10 -0
- package/types/formats/index.d.ts +24 -0
- package/types/formats/utils.d.ts +41 -0
- package/types/index.d.ts +27 -0
- package/types/validators/index.d.ts +68 -0
- package/dist/common-types-plugin.dev.js +0 -11388
- package/dist/common-types-plugin.prod.js +0 -2
- package/dist/index.d.ts +0 -260
- package/dist/xlr/BooleanType.json +0 -72
- package/dist/xlr/CollectionType.json +0 -39
- package/dist/xlr/DateType.json +0 -55
- package/dist/xlr/IntegerNNType.json +0 -75
- package/dist/xlr/IntegerPosType.json +0 -75
- package/dist/xlr/IntegerType.json +0 -55
- package/dist/xlr/PhoneType.json +0 -55
- package/dist/xlr/StringType.json +0 -62
- package/dist/xlr/manifest.js +0 -21
- package/dist/xlr/manifest.json +0 -26
- package/src/data-types/refs.ts +0 -33
package/src/validators/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import type { ValidatorFunction } from '@player-ui/player';
|
|
1
|
+
import { resolveDataRefs } from "@player-ui/player";
|
|
2
|
+
import type { ValidatorFunction, Expression } from "@player-ui/player";
|
|
4
3
|
|
|
5
4
|
// Shamelessly lifted from Scott Gonzalez via the Bassistance Validation plugin http://projects.scottsplayground.com/email_address_validation/
|
|
6
5
|
|
|
@@ -11,7 +10,7 @@ const ZIP_REGEX = /^\d{5}(-\d{4})?$/;
|
|
|
11
10
|
|
|
12
11
|
/** Skip any null or undefined value when running the validator */
|
|
13
12
|
function skipNullish<T>(
|
|
14
|
-
validationFn: ValidatorFunction<T
|
|
13
|
+
validationFn: ValidatorFunction<T>,
|
|
15
14
|
): ValidatorFunction<T> {
|
|
16
15
|
return (context, value, options) => {
|
|
17
16
|
if (value === null || value === undefined) {
|
|
@@ -24,11 +23,11 @@ function skipNullish<T>(
|
|
|
24
23
|
|
|
25
24
|
/** Checks to see if the data-type is a string */
|
|
26
25
|
export const string: ValidatorFunction = skipNullish((context, value) => {
|
|
27
|
-
if (typeof value !==
|
|
26
|
+
if (typeof value !== "string") {
|
|
28
27
|
const message = context.constants.getConstants(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
"validation.string",
|
|
29
|
+
"constants",
|
|
30
|
+
"Value must be a string",
|
|
32
31
|
) as string;
|
|
33
32
|
|
|
34
33
|
return {
|
|
@@ -43,9 +42,9 @@ export const string: ValidatorFunction = skipNullish((context, value) => {
|
|
|
43
42
|
/** Validation for a non-mutable property */
|
|
44
43
|
export const readonly: ValidatorFunction = (context) => {
|
|
45
44
|
const message = context.constants.getConstants(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
"validation.readonly",
|
|
46
|
+
"constants",
|
|
47
|
+
"Value cannot be modified",
|
|
49
48
|
) as string;
|
|
50
49
|
|
|
51
50
|
return { message };
|
|
@@ -55,9 +54,9 @@ export const readonly: ValidatorFunction = (context) => {
|
|
|
55
54
|
export const collection: ValidatorFunction = skipNullish((context, value) => {
|
|
56
55
|
if (!Array.isArray(value)) {
|
|
57
56
|
const message = context.constants.getConstants(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
"validation.collection",
|
|
58
|
+
"constants",
|
|
59
|
+
"Cannot set collection to non-array",
|
|
61
60
|
) as string;
|
|
62
61
|
|
|
63
62
|
return { message };
|
|
@@ -68,15 +67,15 @@ export const collection: ValidatorFunction = skipNullish((context, value) => {
|
|
|
68
67
|
export const integer: ValidatorFunction = skipNullish((context, value) => {
|
|
69
68
|
if (
|
|
70
69
|
value &&
|
|
71
|
-
(typeof value !==
|
|
70
|
+
(typeof value !== "number" ||
|
|
72
71
|
Math.floor(value) !== value ||
|
|
73
72
|
Number(value) > Number.MAX_SAFE_INTEGER ||
|
|
74
73
|
Number(value) < Number.MIN_SAFE_INTEGER)
|
|
75
74
|
) {
|
|
76
75
|
const message = context.constants.getConstants(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
"validation.integer",
|
|
77
|
+
"constants",
|
|
78
|
+
"Value must be an integer",
|
|
80
79
|
) as string;
|
|
81
80
|
|
|
82
81
|
return {
|
|
@@ -99,9 +98,9 @@ export const oneOf: ValidatorFunction<{
|
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
const message = context.constants.getConstants(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
"validation.oneOf",
|
|
102
|
+
"constants",
|
|
103
|
+
"Invalid entry",
|
|
105
104
|
) as string;
|
|
106
105
|
|
|
107
106
|
return { message };
|
|
@@ -116,7 +115,7 @@ export const expression: ValidatorFunction<{
|
|
|
116
115
|
exp: Expression;
|
|
117
116
|
}> = (context, value, options?) => {
|
|
118
117
|
if (options?.exp === undefined) {
|
|
119
|
-
context.logger.warn(
|
|
118
|
+
context.logger.warn("No expression defined for validation");
|
|
120
119
|
|
|
121
120
|
return;
|
|
122
121
|
}
|
|
@@ -125,9 +124,9 @@ export const expression: ValidatorFunction<{
|
|
|
125
124
|
|
|
126
125
|
if (!result) {
|
|
127
126
|
const message = context.constants.getConstants(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
"validation.expression",
|
|
128
|
+
"constants",
|
|
129
|
+
"Expression evaluation failed",
|
|
131
130
|
) as string;
|
|
132
131
|
|
|
133
132
|
return { message };
|
|
@@ -150,14 +149,14 @@ export const required: ValidatorFunction<{
|
|
|
150
149
|
return;
|
|
151
150
|
}
|
|
152
151
|
|
|
153
|
-
if (value === undefined || value === null || value ===
|
|
152
|
+
if (value === undefined || value === null || value === "") {
|
|
154
153
|
const message = context.constants.getConstants(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
"validation.required",
|
|
155
|
+
"constants",
|
|
156
|
+
"A value is required",
|
|
158
157
|
) as string;
|
|
159
158
|
|
|
160
|
-
return { message, severity:
|
|
159
|
+
return { message, severity: "error" };
|
|
161
160
|
}
|
|
162
161
|
};
|
|
163
162
|
|
|
@@ -172,8 +171,8 @@ export const regex: ValidatorFunction<{
|
|
|
172
171
|
if (
|
|
173
172
|
value === undefined ||
|
|
174
173
|
value === null ||
|
|
175
|
-
value ===
|
|
176
|
-
typeof options?.regex !==
|
|
174
|
+
value === "" ||
|
|
175
|
+
typeof options?.regex !== "string"
|
|
177
176
|
) {
|
|
178
177
|
return;
|
|
179
178
|
}
|
|
@@ -188,9 +187,9 @@ export const regex: ValidatorFunction<{
|
|
|
188
187
|
|
|
189
188
|
if (!regexp.test(value)) {
|
|
190
189
|
const message = context.constants.getConstants(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
"validation.regex",
|
|
191
|
+
"constants",
|
|
192
|
+
"Invalid entry",
|
|
194
193
|
) as string;
|
|
195
194
|
|
|
196
195
|
return { message };
|
|
@@ -211,31 +210,31 @@ export const length: ValidatorFunction<
|
|
|
211
210
|
exact: number;
|
|
212
211
|
}
|
|
213
212
|
> = skipNullish((context, value, options) => {
|
|
214
|
-
if (typeof options !==
|
|
215
|
-
context.logger.warn(
|
|
213
|
+
if (typeof options !== "object") {
|
|
214
|
+
context.logger.warn("Missing comparison in length validation");
|
|
216
215
|
|
|
217
216
|
return;
|
|
218
217
|
}
|
|
219
218
|
|
|
220
219
|
let valLength: number | undefined;
|
|
221
|
-
let itemName =
|
|
220
|
+
let itemName = "items";
|
|
222
221
|
|
|
223
|
-
if (typeof value ===
|
|
222
|
+
if (typeof value === "string") {
|
|
224
223
|
valLength = value.length;
|
|
225
|
-
itemName =
|
|
226
|
-
} else if (typeof value ===
|
|
224
|
+
itemName = "characters";
|
|
225
|
+
} else if (typeof value === "object" && value !== null) {
|
|
227
226
|
valLength = Object.keys(value).length;
|
|
228
227
|
}
|
|
229
228
|
|
|
230
229
|
if (valLength === undefined) {
|
|
231
230
|
context.logger.warn(
|
|
232
|
-
`Unable to determine a length for value of type: ${value}
|
|
231
|
+
`Unable to determine a length for value of type: ${value}`,
|
|
233
232
|
);
|
|
234
233
|
|
|
235
234
|
return;
|
|
236
235
|
}
|
|
237
236
|
|
|
238
|
-
if (
|
|
237
|
+
if ("exact" in options) {
|
|
239
238
|
if (valLength !== options.exact) {
|
|
240
239
|
return {
|
|
241
240
|
message: `Must be exactly ${options.exact} ${itemName} long`,
|
|
@@ -250,9 +249,9 @@ export const length: ValidatorFunction<
|
|
|
250
249
|
|
|
251
250
|
if (options.min !== undefined && valLength < options.min) {
|
|
252
251
|
const message = context.constants.getConstants(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
`At least ${options.min} ${itemName} needed
|
|
252
|
+
"validation.length.minimum",
|
|
253
|
+
"constants",
|
|
254
|
+
`At least ${options.min} ${itemName} needed`,
|
|
256
255
|
) as string;
|
|
257
256
|
|
|
258
257
|
return {
|
|
@@ -265,9 +264,9 @@ export const length: ValidatorFunction<
|
|
|
265
264
|
|
|
266
265
|
if (options.max !== undefined && valLength > options.max) {
|
|
267
266
|
const message = context.constants.getConstants(
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
`Up to ${options.max} ${itemName} allowed
|
|
267
|
+
"validation.length.maximum",
|
|
268
|
+
"constants",
|
|
269
|
+
`Up to ${options.max} ${itemName} allowed`,
|
|
271
270
|
) as string;
|
|
272
271
|
|
|
273
272
|
return {
|
|
@@ -286,15 +285,15 @@ export const min: ValidatorFunction<{
|
|
|
286
285
|
/** The minimum value */
|
|
287
286
|
value: number;
|
|
288
287
|
}> = skipNullish((context, value, options) => {
|
|
289
|
-
if (typeof value !==
|
|
288
|
+
if (typeof value !== "number" || options?.value === undefined) {
|
|
290
289
|
return;
|
|
291
290
|
}
|
|
292
291
|
|
|
293
292
|
if (value < options.value) {
|
|
294
293
|
const message = context.constants.getConstants(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
`Must be at least ${options.value}
|
|
294
|
+
"validation.min",
|
|
295
|
+
"constants",
|
|
296
|
+
`Must be at least ${options.value}`,
|
|
298
297
|
) as string;
|
|
299
298
|
|
|
300
299
|
return { message };
|
|
@@ -308,15 +307,15 @@ export const max: ValidatorFunction<{
|
|
|
308
307
|
/** The minimum value */
|
|
309
308
|
value: number;
|
|
310
309
|
}> = skipNullish((context, value, options) => {
|
|
311
|
-
if (typeof value !==
|
|
310
|
+
if (typeof value !== "number" || options?.value === undefined) {
|
|
312
311
|
return;
|
|
313
312
|
}
|
|
314
313
|
|
|
315
314
|
if (value > options.value) {
|
|
316
315
|
const message = context.constants.getConstants(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
`Cannot exceed ${options.value}
|
|
316
|
+
"validation.max",
|
|
317
|
+
"constants",
|
|
318
|
+
`Cannot exceed ${options.value}`,
|
|
320
319
|
) as string;
|
|
321
320
|
|
|
322
321
|
return { message };
|
|
@@ -327,18 +326,18 @@ export const max: ValidatorFunction<{
|
|
|
327
326
|
const stringRegexValidator = (
|
|
328
327
|
test: RegExp,
|
|
329
328
|
messagePath: string,
|
|
330
|
-
invalidMessage: string
|
|
329
|
+
invalidMessage: string,
|
|
331
330
|
): ValidatorFunction => {
|
|
332
331
|
return skipNullish((context, value) => {
|
|
333
|
-
if (typeof value ===
|
|
332
|
+
if (typeof value === "string" && value === "") {
|
|
334
333
|
return;
|
|
335
334
|
}
|
|
336
335
|
|
|
337
|
-
if (typeof value !==
|
|
336
|
+
if (typeof value !== "string" || !test.test(value)) {
|
|
338
337
|
const message = context.constants.getConstants(
|
|
339
338
|
messagePath,
|
|
340
|
-
|
|
341
|
-
invalidMessage
|
|
339
|
+
"constants",
|
|
340
|
+
invalidMessage,
|
|
342
341
|
) as string;
|
|
343
342
|
|
|
344
343
|
return { message };
|
|
@@ -349,20 +348,20 @@ const stringRegexValidator = (
|
|
|
349
348
|
/** Checks that the given value represents an email */
|
|
350
349
|
export const email = stringRegexValidator(
|
|
351
350
|
EMAIL_REGEX,
|
|
352
|
-
|
|
353
|
-
|
|
351
|
+
"validation.email",
|
|
352
|
+
"Improper email format",
|
|
354
353
|
);
|
|
355
354
|
|
|
356
355
|
/** Checks that the given value represents a phone number */
|
|
357
356
|
export const phone = stringRegexValidator(
|
|
358
357
|
PHONE_REGEX,
|
|
359
|
-
|
|
360
|
-
|
|
358
|
+
"validation.phone",
|
|
359
|
+
"Invalid phone number",
|
|
361
360
|
);
|
|
362
361
|
|
|
363
362
|
/** Checks that the given value represents a phone number */
|
|
364
363
|
export const zip = stringRegexValidator(
|
|
365
364
|
ZIP_REGEX,
|
|
366
|
-
|
|
367
|
-
|
|
365
|
+
"validation.regex",
|
|
366
|
+
"Invalid zip code",
|
|
368
367
|
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Schema } from "@player-ui/player";
|
|
2
|
+
export declare const BooleanType: Schema.DataType<boolean>;
|
|
3
|
+
export declare const IntegerType: Schema.DataType<number>;
|
|
4
|
+
export declare const IntegerPosType: Schema.DataType<number>;
|
|
5
|
+
export declare const IntegerNNType: Schema.DataType<number>;
|
|
6
|
+
export declare const StringType: Schema.DataType<string>;
|
|
7
|
+
export declare const CollectionType: Schema.DataType<Array<unknown>>;
|
|
8
|
+
export declare const DateType: Schema.DataType<string>;
|
|
9
|
+
export declare const PhoneType: Schema.DataType<string>;
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FormatType } from "@player-ui/player";
|
|
2
|
+
/**
|
|
3
|
+
* Converts an integer to and from a string for display
|
|
4
|
+
*/
|
|
5
|
+
export declare const integer: FormatType<number, string>;
|
|
6
|
+
/** Converts a number to/from a comma separated version */
|
|
7
|
+
export declare const commaNumber: FormatType<number, string, {
|
|
8
|
+
/** The number of decimal places to show */
|
|
9
|
+
precision?: number;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const date: FormatType<string, string, {
|
|
12
|
+
/** The mask to use to format the date */
|
|
13
|
+
mask?: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const currency: FormatType<number, string, {
|
|
16
|
+
/** The symbol to use for currency */
|
|
17
|
+
currencySymbol?: string;
|
|
18
|
+
/** Use parenthesis instead of a - sign for negative values */
|
|
19
|
+
useParensForNeg?: boolean;
|
|
20
|
+
/** The number of decimal places to show */
|
|
21
|
+
precision?: number;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const phone: FormatType<string>;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { FormatType } from "@player-ui/player";
|
|
2
|
+
export declare const PLACEHOLDER = "#";
|
|
3
|
+
/**
|
|
4
|
+
* Remove any formatting characters in the 'mask' from 'value'
|
|
5
|
+
*
|
|
6
|
+
* @param value - The string to remove the control characters from
|
|
7
|
+
* @param mask - The mask to use and test against
|
|
8
|
+
* @param reserved - The reserved _slots_ (these are the chars that you expect new values to be subbed into)
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* removeFormatCharactersFromMaskedString('123-456', '###-###', ['#']) => '123456'
|
|
12
|
+
*/
|
|
13
|
+
export declare const removeFormatCharactersFromMaskedString: (value: string, mask: string, reserved?: string[]) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Format the given string using one of the accepted values
|
|
16
|
+
* Optionally, the value can be choose to ignore case when formatting, or to autocomplete if only 1 option is viable
|
|
17
|
+
* If no such option is viable, undefined is returned
|
|
18
|
+
*/
|
|
19
|
+
export declare const formatAsEnum: (value: string, acceptedValues: string[], options?: {
|
|
20
|
+
/** Ignore the case of the provided value when comparing to the acceptedValues */
|
|
21
|
+
ignoreCase?: boolean;
|
|
22
|
+
/** If only 1 option is viable, autocomplete the value to the accepted one */
|
|
23
|
+
autocomplete?: boolean;
|
|
24
|
+
}) => string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Format the given value using the mask + match
|
|
27
|
+
*
|
|
28
|
+
* @param value - The string value to format
|
|
29
|
+
* @param valueCharMaskMatch - A regular expression that matches characters to substitute in the match. This is typically `/\d/g` or `/\w/g`
|
|
30
|
+
* @param mask - The mask to format against. Use # as a placeholder for
|
|
31
|
+
*/
|
|
32
|
+
export declare const formatAsMasked: (value: string | number, valueCharMaskMatch: RegExp, mask: string) => string;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a format definition with the given mask
|
|
35
|
+
* Use the `#` char as a placeholder for a number
|
|
36
|
+
*/
|
|
37
|
+
export declare const createMaskedNumericFormatter: (name: string, mask: string) => FormatType<string, string, {
|
|
38
|
+
/** An enum of values that are also acceptable, and don't fall under the mask */
|
|
39
|
+
exceptions?: Array<string>;
|
|
40
|
+
}>;
|
|
41
|
+
//# sourceMappingURL=utils.d.ts.map
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Player, ExtendedPlayerPlugin } from "@player-ui/player";
|
|
2
|
+
import * as validators from "./validators";
|
|
3
|
+
import * as dataTypes from "./data-types/types";
|
|
4
|
+
import * as formats from "./formats";
|
|
5
|
+
import type { BooleanType, IntegerType, IntegerPosType, IntegerNNType, StringType, CollectionType, DateType, PhoneType } from "./data-types/types";
|
|
6
|
+
export { validators, dataTypes, formats };
|
|
7
|
+
export * from "./formats/utils";
|
|
8
|
+
/**
|
|
9
|
+
* Exposes a lot of common DataTypes, validations, and formats to Player instance.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CommonTypesPlugin implements ExtendedPlayerPlugin<[
|
|
12
|
+
], [
|
|
13
|
+
], [
|
|
14
|
+
], [
|
|
15
|
+
typeof BooleanType,
|
|
16
|
+
typeof IntegerType,
|
|
17
|
+
typeof IntegerPosType,
|
|
18
|
+
typeof IntegerNNType,
|
|
19
|
+
typeof StringType,
|
|
20
|
+
typeof CollectionType,
|
|
21
|
+
typeof DateType,
|
|
22
|
+
typeof PhoneType
|
|
23
|
+
]> {
|
|
24
|
+
name: string;
|
|
25
|
+
apply(player: Player): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ValidatorFunction, Expression } from "@player-ui/player";
|
|
2
|
+
/** Checks to see if the data-type is a string */
|
|
3
|
+
export declare const string: ValidatorFunction;
|
|
4
|
+
/** Validation for a non-mutable property */
|
|
5
|
+
export declare const readonly: ValidatorFunction;
|
|
6
|
+
/** Check to see if the value represents an array of items */
|
|
7
|
+
export declare const collection: ValidatorFunction;
|
|
8
|
+
/** Checks to see if the value is an integer */
|
|
9
|
+
export declare const integer: ValidatorFunction;
|
|
10
|
+
/** An enum check to see if the value is in a provided list of acceptable options */
|
|
11
|
+
export declare const oneOf: ValidatorFunction<{
|
|
12
|
+
/** The enum values that are acceptable */
|
|
13
|
+
options: Array<unknown>;
|
|
14
|
+
}>;
|
|
15
|
+
/** A validator that evaluates an expression for validation */
|
|
16
|
+
export declare const expression: ValidatorFunction<{
|
|
17
|
+
/**
|
|
18
|
+
* The expression to evaluate.
|
|
19
|
+
* Falsy values indicate an invalid response
|
|
20
|
+
*/
|
|
21
|
+
exp: Expression;
|
|
22
|
+
}>;
|
|
23
|
+
/** A validator that requires a non-null value */
|
|
24
|
+
export declare const required: ValidatorFunction<{
|
|
25
|
+
/** An optional expression to limit the required check only if true */
|
|
26
|
+
if?: Expression;
|
|
27
|
+
/** An optional expression to limit the required check only if false */
|
|
28
|
+
ifNot?: Expression;
|
|
29
|
+
}>;
|
|
30
|
+
/** A validator that uses a regular expression */
|
|
31
|
+
export declare const regex: ValidatorFunction<{
|
|
32
|
+
/**
|
|
33
|
+
* The regular expression to test: /pattern/
|
|
34
|
+
* Can optionally include flags after the pattern: /pattern/flags
|
|
35
|
+
*/
|
|
36
|
+
regex: string;
|
|
37
|
+
}>;
|
|
38
|
+
/** Checks the length of a value */
|
|
39
|
+
export declare const length: ValidatorFunction<{
|
|
40
|
+
/** The minimum length to check against */
|
|
41
|
+
min?: number;
|
|
42
|
+
/** The maximum length to check against */
|
|
43
|
+
max?: number;
|
|
44
|
+
} | {
|
|
45
|
+
/** The exact length to match against */
|
|
46
|
+
exact: number;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Checks that the given value is at least the expected one
|
|
50
|
+
*/
|
|
51
|
+
export declare const min: ValidatorFunction<{
|
|
52
|
+
/** The minimum value */
|
|
53
|
+
value: number;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Checks that the given value is at least the expected one
|
|
57
|
+
*/
|
|
58
|
+
export declare const max: ValidatorFunction<{
|
|
59
|
+
/** The minimum value */
|
|
60
|
+
value: number;
|
|
61
|
+
}>;
|
|
62
|
+
/** Checks that the given value represents an email */
|
|
63
|
+
export declare const email: ValidatorFunction;
|
|
64
|
+
/** Checks that the given value represents a phone number */
|
|
65
|
+
export declare const phone: ValidatorFunction;
|
|
66
|
+
/** Checks that the given value represents a phone number */
|
|
67
|
+
export declare const zip: ValidatorFunction;
|
|
68
|
+
//# sourceMappingURL=index.d.ts.map
|