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