1 | import * as _isBoolean from "./lib/isBoolean";
|
2 | import * as _isEmail from "./lib/isEmail";
|
3 | import * as _isFQDN from "./lib/isFQDN";
|
4 | import * as _isIBAN from "./lib/isIBAN";
|
5 | import * as _isISO31661Alpha2 from "./lib/isISO31661Alpha2";
|
6 | import * as _isISO4217 from "./lib/isISO4217";
|
7 | import * as _isISO6391 from "./lib/isISO6391";
|
8 | import * as _isTaxID from "./lib/isTaxID";
|
9 | import * as _isURL from "./lib/isURL";
|
10 |
|
11 | declare namespace validator {
|
12 | export const version: string;
|
13 |
|
14 | /******************
|
15 | *** Validators ***
|
16 | ******************/
|
17 |
|
18 | export interface ContainsOptions {
|
19 | /**
|
20 | * @default false
|
21 | */
|
22 | ignoreCase?: boolean | undefined;
|
23 | /**
|
24 | * @default 1
|
25 | */
|
26 | minOccurrences?: number | undefined;
|
27 | }
|
28 |
|
29 | /**
|
30 | * Check if the string contains the seed.
|
31 | *
|
32 | * @param seed - Seed
|
33 | */
|
34 | export function contains(str: string, seed: any, options?: ContainsOptions): boolean;
|
35 |
|
36 | /**
|
37 | * Check if the string matches the comparison.
|
38 | *
|
39 | * @param comparison - String to compare
|
40 | */
|
41 | export function equals(str: string, comparison: string): boolean;
|
42 |
|
43 | /**
|
44 | * Check if the string is a date that's after the specified date.
|
45 | *
|
46 | * @param [date] - Date string (defaults to now)
|
47 | */
|
48 | export function isAfter(str: string, date?: string): boolean;
|
49 |
|
50 | export type AlphaLocale =
|
51 | | "en-US"
|
52 | | "bg-BG"
|
53 | | "cs-CZ"
|
54 | | "da-DK"
|
55 | | "de-DE"
|
56 | | "el-GR"
|
57 | | "es-AR"
|
58 | | "es-ES"
|
59 | | "fr-FR"
|
60 | | "it-IT"
|
61 | | "nb-NO"
|
62 | | "nl-NL"
|
63 | | "nn-NO"
|
64 | | "hu-HU"
|
65 | | "pl-PL"
|
66 | | "pt-PT"
|
67 | | "ru-RU"
|
68 | | "sl-SI"
|
69 | | "sk-SK"
|
70 | | "sr-RS@latin"
|
71 | | "sr-RS"
|
72 | | "sv-SE"
|
73 | | "tr-TR"
|
74 | | "uk-UA"
|
75 | | "ku-IQ"
|
76 | | "ar"
|
77 | | "he"
|
78 | | "fa-IR"
|
79 | | "en-AU"
|
80 | | "en-GB"
|
81 | | "en-HK"
|
82 | | "en-IN"
|
83 | | "en-NZ"
|
84 | | "en-ZA"
|
85 | | "en-ZM"
|
86 | | "ar-AE"
|
87 | | "ar-BH"
|
88 | | "ar-DZ"
|
89 | | "ar-EG"
|
90 | | "ar-IQ"
|
91 | | "ar-JO"
|
92 | | "ar-KW"
|
93 | | "ar-LB"
|
94 | | "ar-LY"
|
95 | | "ar-MA"
|
96 | | "ar-QM"
|
97 | | "ar-QA"
|
98 | | "ar-SA"
|
99 | | "ar-SD"
|
100 | | "ar-SY"
|
101 | | "ar-TN"
|
102 | | "ar-YE"
|
103 | | "pt-BR"
|
104 | | "pl-Pl";
|
105 |
|
106 | export const isAlphaLocales: AlphaLocale[];
|
107 |
|
108 | export interface IsAlphaOptions {
|
109 | /**
|
110 | * @default undefined
|
111 | */
|
112 | ignore?: string | RegExp | undefined;
|
113 | }
|
114 |
|
115 | /**
|
116 | * Check if the string contains only letters (a-zA-Z).
|
117 | *
|
118 | * @param [locale] - AlphaLocale
|
119 | * @param [options] - IsAlphaOptions
|
120 | */
|
121 | export function isAlpha(str: string, locale?: AlphaLocale, options?: IsAlphaOptions): boolean;
|
122 |
|
123 | export type AlphanumericLocale =
|
124 | | "en-US"
|
125 | | "bg-BG"
|
126 | | "cs-CZ"
|
127 | | "da-DK"
|
128 | | "de-DE"
|
129 | | "el-GR"
|
130 | | "es-AR"
|
131 | | "es-ES"
|
132 | | "fr-FR"
|
133 | | "it-IT"
|
134 | | "hu-HU"
|
135 | | "nb-NO"
|
136 | | "nl-NL"
|
137 | | "nn-NO"
|
138 | | "pl-PL"
|
139 | | "pt-PT"
|
140 | | "ru-RU"
|
141 | | "sl-SI"
|
142 | | "sk-SK"
|
143 | | "sr-RS@latin"
|
144 | | "sr-RS"
|
145 | | "sv-SE"
|
146 | | "tr-TR"
|
147 | | "uk-UA"
|
148 | | "ku-IQ"
|
149 | | "ar"
|
150 | | "he"
|
151 | | "fa-IR"
|
152 | | "en-AU"
|
153 | | "en-GB"
|
154 | | "en-HK"
|
155 | | "en-IN"
|
156 | | "en-NZ"
|
157 | | "en-ZA"
|
158 | | "en-ZM"
|
159 | | "ar-AE"
|
160 | | "ar-BH"
|
161 | | "ar-DZ"
|
162 | | "ar-EG"
|
163 | | "ar-IQ"
|
164 | | "ar-JO"
|
165 | | "ar-KW"
|
166 | | "ar-LB"
|
167 | | "ar-LY"
|
168 | | "ar-MA"
|
169 | | "ar-QM"
|
170 | | "ar-QA"
|
171 | | "ar-SA"
|
172 | | "ar-SD"
|
173 | | "ar-SY"
|
174 | | "ar-TN"
|
175 | | "ar-YE"
|
176 | | "pt-BR"
|
177 | | "pl-Pl";
|
178 |
|
179 | export const isAlphanumericLocales: AlphanumericLocale[];
|
180 |
|
181 | export interface IsAlphanumericOptions {
|
182 | /**
|
183 | * @default undefined
|
184 | */
|
185 | ignore?: string | RegExp | undefined;
|
186 | }
|
187 |
|
188 | /**
|
189 | * Check if the string contains only letters and numbers.
|
190 | *
|
191 | * @param [locale] - AlphanumericLocale
|
192 | * @param [options] - IsAlphanumericOptions
|
193 | */
|
194 | export function isAlphanumeric(str: string, locale?: AlphanumericLocale, options?: IsAlphanumericOptions): boolean;
|
195 |
|
196 | /**
|
197 | * Check if the string contains ASCII chars only.
|
198 | */
|
199 | export function isAscii(str: string): boolean;
|
200 |
|
201 | /**
|
202 | * Check if a string is base32 encoded.
|
203 | */
|
204 | export function isBase32(str: string): boolean;
|
205 | /**
|
206 | * check if a string is base58 encoded
|
207 | */
|
208 | export function isBase58(str: string): boolean;
|
209 |
|
210 | export interface IsBase64Options {
|
211 | /**
|
212 | * @default false
|
213 | */
|
214 | urlSafe?: boolean | undefined;
|
215 | }
|
216 |
|
217 | /**
|
218 | * Check if a string is base64 encoded.
|
219 | *
|
220 | * @param [options] - Options
|
221 | */
|
222 | export function isBase64(str: string, options?: IsBase64Options): boolean;
|
223 |
|
224 | /**
|
225 | * Check if the string is a date that's before the specified date.
|
226 | *
|
227 | * @param [date] - Date string (defaults to now)
|
228 | */
|
229 | export function isBefore(str: string, date?: string): boolean;
|
230 |
|
231 | export const isIBAN: typeof _isIBAN.default;
|
232 | export const ibanLocales: typeof _isIBAN.locales;
|
233 |
|
234 | /**
|
235 | * Check if a string is a BIC (Bank Identification Code) or SWIFT code.
|
236 | */
|
237 | export function isBIC(str: string): boolean;
|
238 |
|
239 | export const isBoolean: typeof _isBoolean.default;
|
240 |
|
241 | export interface IsByteLengthOptions {
|
242 | /**
|
243 | * @default 0
|
244 | */
|
245 | min?: number | undefined;
|
246 | /**
|
247 | * @default undefined
|
248 | */
|
249 | max?: number | undefined;
|
250 | }
|
251 |
|
252 | /**
|
253 | * Check if the string's length (in UTF-8 bytes) falls in a range.
|
254 | *
|
255 | * @param [options] - Options
|
256 | */
|
257 | export function isByteLength(str: string, options?: IsByteLengthOptions): boolean;
|
258 |
|
259 | export interface IsCreditCardOptions {
|
260 | /**
|
261 | * @default undefined
|
262 | */
|
263 | provider?: "amex" | "dinersclub" | "discover" | "jcb" | "mastercard" | "unionpay" | "visa" | "";
|
264 | }
|
265 |
|
266 | /**
|
267 | * Check if the string is a credit card.
|
268 | */
|
269 | export function isCreditCard(str: string, options?: IsCreditCardOptions): boolean;
|
270 |
|
271 | export interface IsCurrencyOptions {
|
272 | /**
|
273 | * @default '$'
|
274 | */
|
275 | symbol?: string | undefined;
|
276 | /**
|
277 | * @default false
|
278 | */
|
279 | require_symbol?: boolean | undefined;
|
280 | /**
|
281 | * @default false
|
282 | */
|
283 | allow_space_after_symbol?: boolean | undefined;
|
284 | /**
|
285 | * @default false
|
286 | */
|
287 | symbol_after_digits?: boolean | undefined;
|
288 | /**
|
289 | * @default true
|
290 | */
|
291 | allow_negatives?: boolean | undefined;
|
292 | /**
|
293 | * @default false
|
294 | */
|
295 | parens_for_negatives?: boolean | undefined;
|
296 | /**
|
297 | * @default false
|
298 | */
|
299 | negative_sign_before_digits?: boolean | undefined;
|
300 | /**
|
301 | * @default false
|
302 | */
|
303 | negative_sign_after_digits?: boolean | undefined;
|
304 | /**
|
305 | * @default false
|
306 | */
|
307 | allow_negative_sign_placeholder?: boolean | undefined;
|
308 | /**
|
309 | * @default ','
|
310 | */
|
311 | thousands_separator?: string | undefined;
|
312 | /**
|
313 | * @default '.'
|
314 | */
|
315 | decimal_separator?: string | undefined;
|
316 | /**
|
317 | * @default true
|
318 | */
|
319 | allow_decimal?: boolean | undefined;
|
320 | /**
|
321 | * @default false
|
322 | */
|
323 | require_decimal?: boolean | undefined;
|
324 | /**
|
325 | * The array `digits_after_decimal` is filled with the exact number of digits allowed not a range, for example a range `1` to `3` will be given as `[1, 2, 3]`.
|
326 | *
|
327 | * @default [2]
|
328 | */
|
329 | digits_after_decimal?: number[] | undefined;
|
330 | /**
|
331 | * @default false
|
332 | */
|
333 | allow_space_after_digits?: boolean | undefined;
|
334 | }
|
335 |
|
336 | /**
|
337 | * Check if the string is a valid currency amount.
|
338 | *
|
339 | * @param [options] - Options
|
340 | */
|
341 | export function isCurrency(str: string, options?: IsCurrencyOptions): boolean;
|
342 |
|
343 | /**
|
344 | * Check if the string is an [Ethereum](https://ethereum.org/) address using basic regex. Does not validate address checksums.
|
345 | */
|
346 | export function isEthereumAddress(str: string): boolean;
|
347 |
|
348 | /**
|
349 | * Check if the string is a valid BTC address.
|
350 | */
|
351 | export function isBtcAddress(str: string): boolean;
|
352 |
|
353 | /**
|
354 | * Check if the string is a [data uri format](https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs).
|
355 | */
|
356 | export function isDataURI(str: string): boolean;
|
357 |
|
358 | export interface IsDateOptions {
|
359 | /**
|
360 | * @default false
|
361 | */
|
362 | format?: string | undefined;
|
363 | /**
|
364 | * If strictMode is set to true,
|
365 | * the validator will reject inputs different from format.
|
366 | *
|
367 | * @default false
|
368 | */
|
369 | strictMode?: boolean | undefined;
|
370 | /**
|
371 | * `delimiters` is an array of allowed date delimiters
|
372 | *
|
373 | * @default ['/', '-']
|
374 | */
|
375 | delimiters?: string[] | undefined;
|
376 | }
|
377 |
|
378 | /**
|
379 | * Check if the string is a valid date.
|
380 | */
|
381 | export function isDate(str: string, options?: IsDateOptions): boolean;
|
382 |
|
383 | export type DecimalLocale = FloatLocale;
|
384 |
|
385 | export interface IsDecimalOptions {
|
386 | /**
|
387 | * @default false
|
388 | */
|
389 | force_decimal?: boolean | undefined;
|
390 | /**
|
391 | * `decimal_digits` is given as a range like `'1,3'`,
|
392 | * a specific value like `'3'` or min like `'1,'`
|
393 | *
|
394 | * @default '1,'
|
395 | */
|
396 | decimal_digits?: string | undefined;
|
397 | /**
|
398 | * DecimalLocale
|
399 | *
|
400 | * @default 'en-US'
|
401 | */
|
402 | locale?: DecimalLocale | undefined;
|
403 | }
|
404 |
|
405 | /**
|
406 | * Check if the string represents a decimal number,
|
407 | * such as `0.1`, `.3`, `1.1`, `1.00003`, `4.0` etc.
|
408 | *
|
409 | * @param [options] - Options
|
410 | */
|
411 | export function isDecimal(str: string, options?: IsDecimalOptions): boolean;
|
412 |
|
413 | /**
|
414 | * Check if the string is a number that's divisible by another.
|
415 | *
|
416 | * @param number - Divider number
|
417 | */
|
418 | export function isDivisibleBy(str: string, number: number): boolean;
|
419 |
|
420 | export type IsEmailOptions = _isEmail.IsEmailOptions;
|
421 | export const isEmail: typeof _isEmail.default;
|
422 |
|
423 | /**
|
424 | * check if the string is a [Magnet URI format][Mailto URI Format].<br/><br/>`options` is an object of validating emails inside the URI (check `isEmail`s options for details).
|
425 | * @param str
|
426 | * @param [options]
|
427 | */
|
428 | export function isMailtoURI(str: string, options?: IsEmailOptions): boolean;
|
429 |
|
430 | export interface IsEmptyOptions {
|
431 | /**
|
432 | * @default false
|
433 | */
|
434 | ignore_whitespace?: boolean | undefined;
|
435 | }
|
436 |
|
437 | /**
|
438 | * Check if the string has a length of zero.
|
439 | *
|
440 | * @param [options] - Options
|
441 | */
|
442 | export function isEmpty(str: string, options?: IsEmptyOptions): boolean;
|
443 |
|
444 | export type FloatLocale =
|
445 | | "en-US"
|
446 | | "ar"
|
447 | | "en-AU"
|
448 | | "en-GB"
|
449 | | "en-HK"
|
450 | | "en-IN"
|
451 | | "en-NZ"
|
452 | | "en-ZA"
|
453 | | "en-ZM"
|
454 | | "ar-AE"
|
455 | | "ar-BH"
|
456 | | "ar-DZ"
|
457 | | "ar-EG"
|
458 | | "ar-IQ"
|
459 | | "ar-JO"
|
460 | | "ar-KW"
|
461 | | "ar-LB"
|
462 | | "ar-LY"
|
463 | | "ar-MA"
|
464 | | "ar-QM"
|
465 | | "ar-QA"
|
466 | | "ar-SA"
|
467 | | "ar-SD"
|
468 | | "ar-SY"
|
469 | | "ar-TN"
|
470 | | "ar-YE"
|
471 | | "bg-BG"
|
472 | | "cs-CZ"
|
473 | | "da-DK"
|
474 | | "de-DE"
|
475 | | "el-GR"
|
476 | | "es-ES"
|
477 | | "fr-FR"
|
478 | | "it-IT"
|
479 | | "ku-IQ"
|
480 | | "hu-HU"
|
481 | | "nb-NO"
|
482 | | "nn-NO"
|
483 | | "nl-NL"
|
484 | | "pl-PL"
|
485 | | "pt-PT"
|
486 | | "ru-RU"
|
487 | | "sl-SI"
|
488 | | "sr-RS@latin"
|
489 | | "sr-RS"
|
490 | | "sv-SE"
|
491 | | "tr-TR"
|
492 | | "uk-UA"
|
493 | | "pt-BR"
|
494 | | "pl-Pl";
|
495 |
|
496 | export const isFloatLocales: FloatLocale[];
|
497 |
|
498 | export interface IsFloatOptions {
|
499 | /**
|
500 | * less or equal
|
501 | */
|
502 | min?: number | undefined;
|
503 | /**
|
504 | * greater or equal
|
505 | */
|
506 | max?: number | undefined;
|
507 | /**
|
508 | * greater than
|
509 | */
|
510 | gt?: number | undefined;
|
511 | /**
|
512 | * less than
|
513 | */
|
514 | lt?: number | undefined;
|
515 | /**
|
516 | * FloatLocale
|
517 | */
|
518 | locale?: FloatLocale | undefined;
|
519 | }
|
520 |
|
521 | /**
|
522 | * Check if the string is a float.
|
523 | *
|
524 | * @param [options] - Options
|
525 | */
|
526 | export function isFloat(str: string, options?: IsFloatOptions): boolean;
|
527 |
|
528 | export type IsFQDNOptions = _isFQDN.IsFQDNOptions;
|
529 | export const isFQDN: typeof _isFQDN.default;
|
530 |
|
531 | /**
|
532 | * Check if the string contains any full-width chars.
|
533 | */
|
534 | export function isFullWidth(str: string): boolean;
|
535 |
|
536 | /**
|
537 | * Check if the string contains any half-width chars.
|
538 | */
|
539 | export function isHalfWidth(str: string): boolean;
|
540 |
|
541 | export type HashAlgorithm =
|
542 | | "md4"
|
543 | | "md5"
|
544 | | "sha1"
|
545 | | "sha256"
|
546 | | "sha384"
|
547 | | "sha512"
|
548 | | "ripemd128"
|
549 | | "ripemd160"
|
550 | | "tiger128"
|
551 | | "tiger160"
|
552 | | "tiger192"
|
553 | | "crc32"
|
554 | | "crc32b";
|
555 |
|
556 | /**
|
557 | * Check if the string is a hash of export type algorithm.
|
558 | *
|
559 | * @param algorithm - HashAlgorithm
|
560 | */
|
561 | export function isHash(str: string, algorithm: HashAlgorithm): boolean;
|
562 |
|
563 | /**
|
564 | * Check if the string is a hexadecimal number.
|
565 | */
|
566 | export function isHexadecimal(str: string): boolean;
|
567 |
|
568 | /**
|
569 | * Check if the string is a hexadecimal color.
|
570 | */
|
571 | export function isHexColor(str: string): boolean;
|
572 |
|
573 | /**
|
574 | * Check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on CSS Colors Level 4 specification.
|
575 | * Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: hsl(200grad+.1%62%/1)).
|
576 | */
|
577 | export function isHSL(str: string): boolean;
|
578 |
|
579 | /**
|
580 | * Check if the string is a rgb or rgba color.
|
581 | *
|
582 | * @param [includePercentValues=true] - If you don't want to allow to set rgb or rgba values with percents, like rgb(5%,5%,5%), or rgba(90%,90%,90%,.3), then set it to false. (defaults to true)
|
583 | */
|
584 | export function isRgbColor(str: string, includePercentValues?: boolean): boolean;
|
585 |
|
586 | export type IdentityCardLocale =
|
587 | | "ar-LY"
|
588 | | "ar-TN"
|
589 | | "ES"
|
590 | | "FI"
|
591 | | "he-IL"
|
592 | | "IN"
|
593 | | "IR"
|
594 | | "IT"
|
595 | | "LK"
|
596 | | "NO"
|
597 | | "PL"
|
598 | | "TH"
|
599 | | "zh-CN"
|
600 | | "zh-HK"
|
601 | | "zh-TW";
|
602 |
|
603 | /**
|
604 | * Check if the string is a valid identity card code.
|
605 | *
|
606 | * @param [locale="any"] - IdentityCardLocale
|
607 | */
|
608 | export function isIdentityCard(str: string, locale?: "any" | IdentityCardLocale): boolean;
|
609 |
|
610 | export interface IsIMEIOptions {
|
611 | /**
|
612 | * This value is `false` by default. Set to `true` to allow IMEI with hyphens.
|
613 | */
|
614 | allow_hyphens?: boolean | undefined;
|
615 | }
|
616 |
|
617 | /**
|
618 | * Check if the string is a valid IMEI.
|
619 | * Non-hyphenated (`###############`) only is supported by default.
|
620 | * Use the `options` param to enable hyphenated (`##-######-######-#`) support.
|
621 | *
|
622 | * @param [options] - Options
|
623 | */
|
624 | export function isIMEI(str: string, options?: IsIMEIOptions): boolean;
|
625 |
|
626 | /**
|
627 | * Check if the string is in a array of allowed values.
|
628 | *
|
629 | * @param values - Allowed values.
|
630 | */
|
631 | export function isIn(str: string, values: any[]): boolean;
|
632 |
|
633 | export interface IsIntOptions {
|
634 | /**
|
635 | * to check the integer min boundary
|
636 | */
|
637 | min?: number | undefined;
|
638 | /**
|
639 | * to check the integer max boundary
|
640 | */
|
641 | max?: number | undefined;
|
642 | /**
|
643 | * if `false`, will disallow integer values with leading zeroes
|
644 | * @default true
|
645 | */
|
646 | allow_leading_zeroes?: boolean | undefined;
|
647 | /**
|
648 | * enforce integers being greater than the value provided
|
649 | */
|
650 | lt?: number | undefined;
|
651 | /**
|
652 | * enforce integers being less than the value provided
|
653 | */
|
654 | gt?: number | undefined;
|
655 | }
|
656 |
|
657 | /**
|
658 | * Check if the string is an integer.
|
659 | *
|
660 | * @param [options] - Options
|
661 | */
|
662 | export function isInt(str: string, options?: IsIntOptions): boolean;
|
663 |
|
664 | export type IPVersion = "4" | "6" | 4 | 6;
|
665 |
|
666 | /**
|
667 | * Check if the string is an IP (version 4 or 6).
|
668 | *
|
669 | * @param [version] - IP Version
|
670 | */
|
671 | export function isIP(str: string, version?: IPVersion): boolean;
|
672 |
|
673 | /**
|
674 | * Check if the string is an IP Range (version 4 or 6).
|
675 | */
|
676 | export function isIPRange(str: string, version?: IPVersion): boolean;
|
677 |
|
678 | export type ISBNVersion = "10" | "13" | 10 | 13;
|
679 |
|
680 | /**
|
681 | * Check if the string is an ISBN (version 10 or 13).
|
682 | *
|
683 | * @param [version] - ISBN Version
|
684 | */
|
685 | export function isISBN(str: string, version?: ISBNVersion): boolean;
|
686 |
|
687 | /**
|
688 | * Check if the string is an EAN (European Article Number).
|
689 | */
|
690 | export function isEAN(str: string): boolean;
|
691 |
|
692 | /**
|
693 | * Check if the string is an [ISIN](https://en.wikipedia.org/wiki/International_Securities_Identification_Number) (stock/security identifier).
|
694 | */
|
695 | export function isISIN(str: string): boolean;
|
696 |
|
697 | export const isISO31661Alpha2: typeof _isISO31661Alpha2.default;
|
698 |
|
699 | /**
|
700 | * Check if the string is a valid [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) officially assigned country code.
|
701 | */
|
702 | export function isISO31661Alpha3(str: string): boolean;
|
703 |
|
704 | /**
|
705 | * check if the string is a valid [ISO 6346](https://en.wikipedia.org/wiki/ISO_6346) shipping container identification.
|
706 | * @param str
|
707 | */
|
708 | export function isISO6346(str: string): boolean;
|
709 |
|
710 | /**
|
711 | * alias for `isISO6346`, check if the string is a valid [ISO 6346](https://en.wikipedia.org/wiki/ISO_6346) shipping container identification.
|
712 | */
|
713 | export const isFreightContainerID: typeof isISO6346;
|
714 |
|
715 | /**
|
716 | * Check if the string is a valid [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) officially assigned language code.
|
717 | */
|
718 | export const isISO6391: typeof _isISO6391.default;
|
719 |
|
720 | export interface IsISO8601Options {
|
721 | /**
|
722 | * If `strict` is `true`, performs additional checks for valid dates,
|
723 | * e.g. invalidates dates like `2009-02-29`.
|
724 | *
|
725 | * @default false
|
726 | */
|
727 | strict?: boolean | undefined;
|
728 | /**
|
729 | * If `strictSeparator` is true, date strings with date and time separated
|
730 | * by anything other than a T will be invalid
|
731 | */
|
732 | strictSeparator?: boolean | undefined;
|
733 | }
|
734 |
|
735 | /**
|
736 | * Check if the string is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date.
|
737 | *
|
738 | * @param [options] - Options
|
739 | */
|
740 | export function isISO8601(str: string, options?: IsISO8601Options): boolean;
|
741 |
|
742 | export interface IsISSNOptions {
|
743 | /**
|
744 | * If `case_sensitive` is `true`, ISSNs with a lowercase `x` as the check digit are rejected.
|
745 | *
|
746 | * @default false
|
747 | */
|
748 | case_sensitive?: boolean | undefined;
|
749 | /**
|
750 | * @default false
|
751 | */
|
752 | require_hyphen?: boolean | undefined;
|
753 | }
|
754 |
|
755 | /**
|
756 | * Check if the string is an [ISSN](https://en.wikipedia.org/wiki/International_Standard_Serial_Number).
|
757 | *
|
758 | * @param [options] - Options
|
759 | */
|
760 | export function isISSN(str: string, options?: IsISSNOptions): boolean;
|
761 |
|
762 | export const isISO4217: typeof _isISO4217.default;
|
763 |
|
764 | /**
|
765 | * Check if the string is a [ISRC](https://en.wikipedia.org/wiki/International_Standard_Recording_Code).
|
766 | */
|
767 | export function isISRC(str: string): boolean;
|
768 |
|
769 | /**
|
770 | * Check if the string is a valid [RFC 3339](https://tools.ietf.org/html/rfc3339) date.
|
771 | */
|
772 | export function isRFC3339(str: string): boolean;
|
773 |
|
774 | /**
|
775 | * Check if the string is valid JSON (note: uses `JSON.parse`).
|
776 | */
|
777 | export function isJSON(str: string): boolean;
|
778 |
|
779 | /**
|
780 | * Check if the string is valid JWT token.
|
781 | */
|
782 | export function isJWT(str: string): boolean;
|
783 |
|
784 | /**
|
785 | * Check if the string is a valid latitude-longitude coordinate in the format:
|
786 | *
|
787 | * `lat,long` or `lat, long`.
|
788 | */
|
789 | export function isLatLong(str: string): boolean;
|
790 |
|
791 | export interface IsLengthOptions {
|
792 | /**
|
793 | * @default 0
|
794 | */
|
795 | min?: number | undefined;
|
796 | /**
|
797 | * @default undefined
|
798 | */
|
799 | max?: number | undefined;
|
800 | }
|
801 |
|
802 | /**
|
803 | * Check if the string's length falls in a range.
|
804 | *
|
805 | * Note: this export function takes into account surrogate pairs.
|
806 | *
|
807 | * @param [options] - Options
|
808 | */
|
809 | export function isLength(str: string, options?: IsLengthOptions): boolean;
|
810 |
|
811 | /**
|
812 | * Check if the string is a locale.
|
813 | */
|
814 | export function isLocale(str: string): boolean;
|
815 |
|
816 | /**
|
817 | * Check if the string is lowercase.
|
818 | */
|
819 | export function isLowercase(str: string): boolean;
|
820 |
|
821 | export interface IsMACAddressOptions {
|
822 | /**
|
823 | * If `no_colons` is `true`, the validator will allow MAC addresses without the colons.
|
824 | * Also, it allows the use of hyphens or spaces.
|
825 | *
|
826 | * e.g. `01 02 03 04 05 ab` or `01-02-03-04-05-ab`.
|
827 | *
|
828 | * @default false
|
829 | * @deprecated use no_separators instead
|
830 | */
|
831 | no_colons?: boolean | undefined;
|
832 | /**
|
833 | * If `no_separators` is `true`, the validator will allow MAC addresses without the colons.
|
834 | * Also, it allows the use of hyphens or spaces.
|
835 | *
|
836 | * e.g. `01 02 03 04 05 ab` or `01-02-03-04-05-ab`.
|
837 | *
|
838 | * @default false
|
839 | */
|
840 | no_separators?: boolean | undefined;
|
841 | /**
|
842 | * Setting `eui` allows for validation against EUI-48 or EUI-64 instead of both.
|
843 | */
|
844 | eui?: "48" | "64" | undefined;
|
845 | }
|
846 |
|
847 | /**
|
848 | * Check if the string is a MAC address.
|
849 | *
|
850 | * @param [options] - Options
|
851 | */
|
852 | export function isMACAddress(str: string, options?: IsMACAddressOptions): boolean;
|
853 |
|
854 | /**
|
855 | * Check if the string is a [magnet uri format](https://en.wikipedia.org/wiki/Magnet_URI_scheme).
|
856 | */
|
857 | export function isMagnetURI(str: string): boolean;
|
858 |
|
859 | /**
|
860 | * Check if the string is a MD5 hash.
|
861 | */
|
862 | export function isMD5(str: string): boolean;
|
863 |
|
864 | /**
|
865 | * Check if the string matches to a valid [MIME export type](https://en.wikipedia.org/wiki/Media_export type) format.
|
866 | */
|
867 | export function isMimeType(str: string): boolean;
|
868 |
|
869 | export type MobilePhoneLocale = PhoneLocale | PhoneLocaleAlias;
|
870 | export type PhoneLocale =
|
871 | | "am-AM"
|
872 | | "ar-AE"
|
873 | | "ar-BH"
|
874 | | "ar-DZ"
|
875 | | "ar-LB"
|
876 | | "ar-EG"
|
877 | | "ar-IQ"
|
878 | | "ar-JO"
|
879 | | "ar-KW"
|
880 | | "ar-LY"
|
881 | | "ar-MA"
|
882 | | "ar-OM"
|
883 | | "ar-SA"
|
884 | | "ar-SY"
|
885 | | "ar-TN"
|
886 | | "az-AZ"
|
887 | | "bs-BA"
|
888 | | "be-BY"
|
889 | | "bg-BG"
|
890 | | "bn-BD"
|
891 | | "ca-AD"
|
892 | | "cs-CZ"
|
893 | | "da-DK"
|
894 | | "de-DE"
|
895 | | "de-AT"
|
896 | | "de-CH"
|
897 | | "de-LU"
|
898 | | "el-GR"
|
899 | | "en-AU"
|
900 | | "en-GB"
|
901 | | "en-GG"
|
902 | | "en-GH"
|
903 | | "en-HK"
|
904 | | "en-MO"
|
905 | | "en-IE"
|
906 | | "en-IN"
|
907 | | "en-KE"
|
908 | | "en-MT"
|
909 | | "en-MU"
|
910 | | "en-NG"
|
911 | | "en-NZ"
|
912 | | "en-PK"
|
913 | | "en-PH"
|
914 | | "en-RW"
|
915 | | "en-SG"
|
916 | | "en-SL"
|
917 | | "en-TZ"
|
918 | | "en-UG"
|
919 | | "en-US"
|
920 | | "en-ZA"
|
921 | | "en-ZM"
|
922 | | "en-ZW"
|
923 | | "es-AR"
|
924 | | "es-BO"
|
925 | | "es-CO"
|
926 | | "es-CL"
|
927 | | "es-CR"
|
928 | | "es-DO"
|
929 | | "es-HN"
|
930 | | "es-EC"
|
931 | | "es-ES"
|
932 | | "es-PE"
|
933 | | "es-MX"
|
934 | | "es-PA"
|
935 | | "es-PY"
|
936 | | "es-UY"
|
937 | | "es-VE"
|
938 | | "et-EE"
|
939 | | "fa-IR"
|
940 | | "fi-FI"
|
941 | | "fj-FJ"
|
942 | | "fo-FO"
|
943 | | "fr-FR"
|
944 | | "fr-GF"
|
945 | | "fr-GP"
|
946 | | "fr-MQ"
|
947 | | "fr-RE"
|
948 | | "he-IL"
|
949 | | "hu-HU"
|
950 | | "id-ID"
|
951 | | "it-IT"
|
952 | | "it-SM"
|
953 | | "ja-JP"
|
954 | | "ka-GE"
|
955 | | "kk-KZ"
|
956 | | "kl-GL"
|
957 | | "ko-KR"
|
958 | | "lt-LT"
|
959 | | "lv-LV"
|
960 | | "ms-MY"
|
961 | | "mz-MZ"
|
962 | | "nb-NO"
|
963 | | "ne-NP"
|
964 | | "nl-BE"
|
965 | | "nl-NL"
|
966 | | "nn-NO"
|
967 | | "pl-PL"
|
968 | | "pt-BR"
|
969 | | "pt-PT"
|
970 | | "pt-AO"
|
971 | | "ro-RO"
|
972 | | "ru-RU"
|
973 | | "si-LK"
|
974 | | "sl-SI"
|
975 | | "sk-SK"
|
976 | | "sq-AL"
|
977 | | "sr-RS"
|
978 | | "sv-SE"
|
979 | | "th-TH"
|
980 | | "tr-TR"
|
981 | | "uk-UA"
|
982 | | "uz-UZ"
|
983 | | "vi-VN"
|
984 | | "zh-CN"
|
985 | | "zh-TW";
|
986 | export type PhoneLocaleAlias = "en-CA" | "fr-CA" | "fr-BE" | "zh-HK" | "zh-MO" | "ga-IE" | "fr-CH" | "it-CH";
|
987 |
|
988 | export const isMobilePhoneLocales: MobilePhoneLocale[];
|
989 |
|
990 | export interface IsMobilePhoneOptions {
|
991 | /**
|
992 | * If this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`.
|
993 | *
|
994 | * @default false
|
995 | */
|
996 | strictMode?: boolean | undefined;
|
997 | }
|
998 |
|
999 | /**
|
1000 | * Check if the string is a mobile phone number.
|
1001 | *
|
1002 | * @param [locale] - MobilePhoneLocale(s)
|
1003 | * @param [options] - Options
|
1004 | */
|
1005 | export function isMobilePhone(
|
1006 | str: string,
|
1007 | locale?: "any" | MobilePhoneLocale | MobilePhoneLocale[],
|
1008 | options?: IsMobilePhoneOptions,
|
1009 | ): boolean;
|
1010 |
|
1011 | /**
|
1012 | * Check if the string is a valid hex-encoded representation of a [MongoDB ObjectId](http://docs.mongodb.org/manual/reference/object-id/).
|
1013 | */
|
1014 | export function isMongoId(str: string): boolean;
|
1015 |
|
1016 | /**
|
1017 | * Check if the string contains one or more multibyte chars.
|
1018 | */
|
1019 | export function isMultibyte(str: string): boolean;
|
1020 |
|
1021 | export interface IsNumericOptions {
|
1022 | /**
|
1023 | * If `no_symbols` is true, the validator will reject numeric strings that feature a symbol (e.g. `+`, `-`, or `.`).
|
1024 | *
|
1025 | * @default false
|
1026 | */
|
1027 | no_symbols?: boolean | undefined;
|
1028 | locale?: AlphaLocale | undefined;
|
1029 | }
|
1030 |
|
1031 | /**
|
1032 | * Check if the string contains only numbers.
|
1033 | *
|
1034 | * @param [options] - Options
|
1035 | */
|
1036 | export function isNumeric(str: string, options?: IsNumericOptions): boolean;
|
1037 |
|
1038 | /**
|
1039 | * Check if the string is a valid octal number.
|
1040 | */
|
1041 | export function isOctal(str: string): boolean;
|
1042 |
|
1043 | /**
|
1044 | * Check if the string is a valid passport number relative to a specific country code.
|
1045 | *
|
1046 | * @param [countryCode] - Country code
|
1047 | */
|
1048 | export function isPassportNumber(str: string, countryCode?: string): boolean;
|
1049 |
|
1050 | /**
|
1051 | * Check if the string is a valid port number.
|
1052 | */
|
1053 | export function isPort(str: string): boolean;
|
1054 |
|
1055 | export type PostalCodeLocale =
|
1056 | | "AD"
|
1057 | | "AT"
|
1058 | | "AU"
|
1059 | | "BE"
|
1060 | | "BG"
|
1061 | | "BR"
|
1062 | | "CA"
|
1063 | | "CH"
|
1064 | | "CN"
|
1065 | | "CZ"
|
1066 | | "DE"
|
1067 | | "DK"
|
1068 | | "DZ"
|
1069 | | "EE"
|
1070 | | "ES"
|
1071 | | "FI"
|
1072 | | "FR"
|
1073 | | "GB"
|
1074 | | "GR"
|
1075 | | "HR"
|
1076 | | "HU"
|
1077 | | "ID"
|
1078 | | "IE"
|
1079 | | "IL"
|
1080 | | "IN"
|
1081 | | "IR"
|
1082 | | "IS"
|
1083 | | "IT"
|
1084 | | "JP"
|
1085 | | "KE"
|
1086 | | "KR"
|
1087 | | "LI"
|
1088 | | "LT"
|
1089 | | "LU"
|
1090 | | "LV"
|
1091 | | "MX"
|
1092 | | "MT"
|
1093 | | "NL"
|
1094 | | "NO"
|
1095 | | "NZ"
|
1096 | | "PL"
|
1097 | | "PR"
|
1098 | | "PT"
|
1099 | | "RO"
|
1100 | | "RU"
|
1101 | | "SA"
|
1102 | | "SE"
|
1103 | | "SI"
|
1104 | | "SK"
|
1105 | | "TN"
|
1106 | | "TW"
|
1107 | | "UA"
|
1108 | | "US"
|
1109 | | "ZA"
|
1110 | | "ZM";
|
1111 |
|
1112 | export const isPostalCodeLocales: PostalCodeLocale[];
|
1113 |
|
1114 | /**
|
1115 | * Check if the string is a postal code
|
1116 | *
|
1117 | * @param locale - PostalCodeLocale
|
1118 | */
|
1119 | export function isPostalCode(str: string, locale: "any" | PostalCodeLocale): boolean;
|
1120 |
|
1121 | /**
|
1122 | * Check if the string is a Semantic Versioning Specification (SemVer).
|
1123 | */
|
1124 | export function isSemVer(str: string): boolean;
|
1125 |
|
1126 | /**
|
1127 | * Check if string is considered a strong password. Allows options to be added
|
1128 | */
|
1129 |
|
1130 | export interface StrongPasswordOptions {
|
1131 | minLength?: number | undefined;
|
1132 | minLowercase?: number | undefined;
|
1133 | minUppercase?: number | undefined;
|
1134 | minNumbers?: number | undefined;
|
1135 | minSymbols?: number | undefined;
|
1136 | returnScore?: boolean | undefined;
|
1137 | pointsPerUnique?: number | undefined;
|
1138 | pointsPerRepeat?: number | undefined;
|
1139 | pointsForContainingLower?: number | undefined;
|
1140 | pointsForContainingUpper?: number | undefined;
|
1141 | pointsForContainingNumber?: number | undefined;
|
1142 | pointsForContainingSymbol?: number | undefined;
|
1143 | }
|
1144 |
|
1145 | export function isStrongPassword(
|
1146 | str: string,
|
1147 | options?: StrongPasswordOptions & { returnScore?: false | undefined },
|
1148 | ): boolean;
|
1149 | export function isStrongPassword(str: string, options: StrongPasswordOptions & { returnScore: true }): number;
|
1150 |
|
1151 | /**
|
1152 | * Check if the string contains any surrogate pairs chars.
|
1153 | */
|
1154 | export function isSurrogatePair(str: string): boolean;
|
1155 |
|
1156 | export interface IsTimeOptions {
|
1157 | /**
|
1158 | * 'hour24' will validate hours in 24 format and 'hour12' will validate hours in 12 format.
|
1159 | * @default 'hour24'
|
1160 | */
|
1161 | hourFormat?: "hour12" | "hour24";
|
1162 | /**
|
1163 | * 'default' will validate HH:MM format, 'withSeconds' will validate the HH:MM:SS format
|
1164 | *
|
1165 | * @default 'default'
|
1166 | */
|
1167 | mode?: "default" | "withSeconds";
|
1168 | }
|
1169 |
|
1170 | /**
|
1171 | * Check if the string is a valid time.
|
1172 | */
|
1173 | export function isTime(str: string, options?: IsTimeOptions): boolean;
|
1174 |
|
1175 | export const isURL: typeof _isURL.default;
|
1176 | export type IsURLOptions = _isURL.IsURLOptions;
|
1177 |
|
1178 | export const isTaxID: typeof _isTaxID.default;
|
1179 |
|
1180 | /**
|
1181 | * Check if the string is uppercase.
|
1182 | */
|
1183 | export function isUppercase(str: string): boolean;
|
1184 |
|
1185 | export type UUIDVersion = "1" | "2" | "3" | "4" | "5" | "all" | 1 | 2 | 3 | 4 | 5;
|
1186 | /**
|
1187 | * Check if the string is a UUID (version 1, 2, 3, 4 or 5).
|
1188 | *
|
1189 | * @param [version="all"] - UUID version
|
1190 | */
|
1191 | export function isUUID(str: string, version?: UUIDVersion): boolean;
|
1192 |
|
1193 | /**
|
1194 | * Check if the string contains a mixture of full and half-width chars.
|
1195 | */
|
1196 | export function isVariableWidth(str: string): boolean;
|
1197 |
|
1198 | /**
|
1199 | * Checks that the string is a [valid VAT number
|
1200 | */
|
1201 | export function isVAT(str: string, countryCode: string): boolean;
|
1202 |
|
1203 | /**
|
1204 | * Checks characters if they appear in the whitelist.
|
1205 | *
|
1206 | * @param chars - whitelist
|
1207 | */
|
1208 | export function isWhitelisted(str: string, chars: string | string[]): boolean;
|
1209 |
|
1210 | /**
|
1211 | * Check if string matches the pattern.
|
1212 | *
|
1213 | * @param pattern - `/foo/i`
|
1214 | */
|
1215 | export function matches(str: string, pattern: RegExp): boolean;
|
1216 | /**
|
1217 | * Check if string matches the pattern.
|
1218 | *
|
1219 | * @param pattern - `'foo'`
|
1220 | * @param [modifiers] - `'i'`
|
1221 | */
|
1222 | export function matches(str: string, pattern: string, modifiers?: string): boolean;
|
1223 |
|
1224 | /**
|
1225 | * Check if the string is of export type slug.
|
1226 | */
|
1227 | export function isSlug(str: string): boolean;
|
1228 |
|
1229 | /******************
|
1230 | *** Sanitizers ***
|
1231 | ******************/
|
1232 |
|
1233 | /**
|
1234 | * Remove characters that appear in the blacklist.
|
1235 | *
|
1236 | * @param chars - The characters are used in a `RegExp` and so you will need to escape some chars, e.g. `blacklist(input, '\\[\\]')`.
|
1237 | */
|
1238 | export function blacklist(input: string, chars: string): string;
|
1239 |
|
1240 | /**
|
1241 | * Replace `<`, `>`, `&`, `'`, `"` and `/` with HTML entities.
|
1242 | */
|
1243 | export function escape(input: string): string;
|
1244 |
|
1245 | /**
|
1246 | * Replaces HTML encoded entities with `<`, `>`, `&`, `'`, `"` and `/`.
|
1247 | */
|
1248 | export function unescape(input: string): string;
|
1249 |
|
1250 | /**
|
1251 | * Trim characters from the left-side of the input.
|
1252 | *
|
1253 | * @param [chars] - characters (defaults to whitespace)
|
1254 | */
|
1255 | export function ltrim(input: string, chars?: string): string;
|
1256 |
|
1257 | export interface NormalizeEmailOptions {
|
1258 | /**
|
1259 | * Transforms the local part (before the @ symbol) of all email addresses to lowercase.
|
1260 | * Please note that this may violate RFC 5321, which gives providers the possibility
|
1261 | * to treat the local part of email addresses in a case sensitive way
|
1262 | * (although in practice most - yet not all - providers don't).
|
1263 | * The domain part of the email address is always lowercased, as it's case insensitive per RFC 1035.
|
1264 | *
|
1265 | * @default true
|
1266 | */
|
1267 | all_lowercase?: boolean | undefined;
|
1268 | /**
|
1269 | * GMail addresses are known to be case-insensitive, so this switch allows lowercasing them even when `all_lowercase` is set to `false`.
|
1270 | * Please note that when `all_lowercase` is `true`, GMail addresses are lowercased regardless of the value of this setting.
|
1271 | *
|
1272 | * @default true
|
1273 | */
|
1274 | gmail_lowercase?: boolean | undefined;
|
1275 | /**
|
1276 | * Removes dots from the local part of the email address, as GMail ignores them
|
1277 | * (e.g. `"john.doe"` and `"johndoe"` are considered equal).
|
1278 | *
|
1279 | * @default true
|
1280 | */
|
1281 | gmail_remove_dots?: boolean | undefined;
|
1282 | /**
|
1283 | * Normalizes addresses by removing "sub-addresses", which is the part following a `"+"` sign
|
1284 | * (e.g. `"foo+bar@gmail.com"` becomes `"foo@gmail.com"`).
|
1285 | *
|
1286 | * @default true
|
1287 | */
|
1288 | gmail_remove_subaddress?: boolean | undefined;
|
1289 | /**
|
1290 | * Converts addresses with domain `@googlemail.com` to `@gmail.com`, as they're equivalent.
|
1291 | *
|
1292 | * @default true
|
1293 | */
|
1294 | gmail_convert_googlemaildotcom?: boolean | undefined;
|
1295 | /**
|
1296 | * Outlook.com addresses (including Windows Live and Hotmail) are known to be case-insensitive, so this switch allows lowercasing them even when `all_lowercase` is set to `false`.
|
1297 | * Please note that when `all_lowercase` is `true`, Outlook.com addresses are lowercased regardless of the value of this setting.
|
1298 | *
|
1299 | * @default true
|
1300 | */
|
1301 | outlookdotcom_lowercase?: boolean | undefined;
|
1302 | /**
|
1303 | * Normalizes addresses by removing "sub-addresses", which is the part following a `"+"` sign
|
1304 | * (e.g. `"foo+bar@outlook.com"` becomes `"foo@outlook.com"`).
|
1305 | *
|
1306 | * @default true
|
1307 | */
|
1308 | outlookdotcom_remove_subaddress?: boolean | undefined;
|
1309 | /**
|
1310 | * Yahoo Mail addresses are known to be case-insensitive, so this switch allows lowercasing them even when `all_lowercase` is set to `false`.
|
1311 | * Please note that when `all_lowercase` is `true`, Yahoo Mail addresses are lowercased regardless of the value of this setting.
|
1312 | *
|
1313 | * @default true
|
1314 | */
|
1315 | yahoo_lowercase?: boolean | undefined;
|
1316 | /**
|
1317 | * Normalizes addresses by removing "sub-addresses", which is the part following a `"-"` sign
|
1318 | * (e.g. `"foo-bar@yahoo.com"` becomes `"foo@yahoo.com"`).
|
1319 | *
|
1320 | * @default true
|
1321 | */
|
1322 | yahoo_remove_subaddress?: boolean | undefined;
|
1323 | /**
|
1324 | * iCloud addresses (including MobileMe) are known to be case-insensitive, so this switch allows lowercasing them even when `all_lowercase` is set to `false`.
|
1325 | * Please note that when `all_lowercase` is `true`, iCloud addresses are lowercased regardless of the value of this setting.
|
1326 | *
|
1327 | * @default true
|
1328 | */
|
1329 | icloud_lowercase?: boolean | undefined;
|
1330 | /**
|
1331 | * Normalizes addresses by removing "sub-addresses", which is the part following a `"+"` sign
|
1332 | * (e.g. `"foo+bar@icloud.com"` becomes `"foo@icloud.com"`).
|
1333 | *
|
1334 | * @default true
|
1335 | */
|
1336 | icloud_remove_subaddress?: boolean | undefined;
|
1337 | }
|
1338 |
|
1339 | /**
|
1340 | * Canonicalizes an email address. (This doesn't validate that the input is an email, if you want to validate the email use `isEmail` beforehand)
|
1341 | *
|
1342 | * @param [options] - Options
|
1343 | */
|
1344 | export function normalizeEmail(email: string, options?: NormalizeEmailOptions): string | false;
|
1345 |
|
1346 | /**
|
1347 | * Trim characters from the right-side of the input.
|
1348 | *
|
1349 | * @param [chars] - characters (defaults to whitespace)
|
1350 | */
|
1351 | export function rtrim(input: string, chars?: string): string;
|
1352 |
|
1353 | /**
|
1354 | * Remove characters with a numerical value < `32` and `127`, mostly control characters.
|
1355 | * Unicode-safe in JavaScript.
|
1356 | *
|
1357 | * @param [keep_new_lines=false] - if `true`, newline characters are preserved (`\n` and `\r`, hex `0xA` and `0xD`).
|
1358 | */
|
1359 | export function stripLow(input: string, keep_new_lines?: boolean): string;
|
1360 |
|
1361 | /**
|
1362 | * Convert the input string to a boolean.
|
1363 | * Everything except for `'0'`, `'false'` and `''` returns `true`.
|
1364 | *
|
1365 | * @param [strict=false] - in `strict` mode, only `'1'` and `'true'` return `true`.
|
1366 | */
|
1367 | export function toBoolean(input: string, strict?: boolean): boolean;
|
1368 |
|
1369 | /**
|
1370 | * Convert the input string to a `Date`, or `null` if the input is not a date.
|
1371 | */
|
1372 | export function toDate(input: string): Date | null;
|
1373 |
|
1374 | /**
|
1375 | * Convert the input string to a float, or `NaN` if the input is not a float.
|
1376 | */
|
1377 | export function toFloat(input: string): number;
|
1378 |
|
1379 | /**
|
1380 | * Convert the input string to an integer, or `NaN` if the input is not an integer.
|
1381 | *
|
1382 | * @param [radix=10] - radix or base (defaults to 10)
|
1383 | */
|
1384 | export function toInt(input: string, radix?: number): number;
|
1385 |
|
1386 | /**
|
1387 | * Trim characters from both sides of the input.
|
1388 | *
|
1389 | * @param [chars] - characters (defaults to whitespace)
|
1390 | */
|
1391 | export function trim(input: string, chars?: string): string;
|
1392 |
|
1393 | /**
|
1394 | * Remove characters that do not appear in the whitelist.
|
1395 | *
|
1396 | * @param chars - The characters are used in a `RegExp` and so you will need to escape some chars, e.g. `whitelist(input, '\\[\\]')`.
|
1397 | */
|
1398 | export function whitelist(input: string, chars: string): string;
|
1399 |
|
1400 | /**
|
1401 | * Converts to string.
|
1402 | */
|
1403 | export function toString(input: any): string;
|
1404 |
|
1405 | export const _default: typeof validator;
|
1406 |
|
1407 | export { _default as default };
|
1408 | }
|
1409 |
|
1410 | // eslint-disable-next-line @definitelytyped/export-just-namespace
|
1411 | export = validator;
|
1412 |
|
1413 | export as namespace validator;
|