mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
validator: updated to v4.5.1
This commit is contained in:
Vendored
+1
-1
@@ -5666,7 +5666,7 @@ declare module "sequelize" {
|
||||
/**
|
||||
* Validator Interface
|
||||
*/
|
||||
interface Validator extends IValidatorStatic {
|
||||
interface Validator extends ValidatorJS.ValidatorStatic {
|
||||
|
||||
notEmpty( str : string ) : boolean;
|
||||
len( str : string, min : number, max : number ) : boolean;
|
||||
|
||||
+137
-55
@@ -1,108 +1,190 @@
|
||||
/// <reference path="./validator.d.ts" />
|
||||
/// <reference path='./validator.d.ts' />
|
||||
|
||||
import validator = require("validator");
|
||||
import * as validator from 'validator';
|
||||
|
||||
let any: any;
|
||||
|
||||
validator.extend("isTest", function(str) {
|
||||
return !str;
|
||||
});
|
||||
/**************
|
||||
* Validators *
|
||||
**************/
|
||||
|
||||
validator.equals("abc", "Abc");
|
||||
{
|
||||
let result: boolean;
|
||||
|
||||
validator.contains("foo", "foobar");
|
||||
result = validator.contains('sample', 'sample');
|
||||
|
||||
validator.matches("foobar", "foo/i");
|
||||
result = validator.equals('sample', 'sample');
|
||||
|
||||
validator.isEmail("sample");
|
||||
result = validator.isAfter('sample');
|
||||
result = validator.isAfter('sample', new Date());
|
||||
|
||||
validator.isURL("sample");
|
||||
result = validator.isAlpha('sample');
|
||||
|
||||
validator.isFQDN("sample");
|
||||
result = validator.isAlphanumeric('sample');
|
||||
|
||||
validator.isMACAddress("sample");
|
||||
result = validator.isAscii('sample');
|
||||
|
||||
validator.isIP("sample");
|
||||
result = validator.isBase64('sample');
|
||||
|
||||
validator.isAlpha("sample");
|
||||
result = validator.isBefore('sample');
|
||||
result = validator.isBefore('sample', new Date());
|
||||
|
||||
validator.isNumeric("sample");
|
||||
result = validator.isBoolean('sample');
|
||||
|
||||
validator.isAlphanumeric("sample");
|
||||
let isByteLengthOptions: ValidatorJS.IsByteLengthOptions;
|
||||
result = validator.isByteLength('sample', isByteLengthOptions);
|
||||
result = validator.isByteLength('sample', 0);
|
||||
result = validator.isByteLength('sample', 0, 42);
|
||||
|
||||
validator.isBase64("sample");
|
||||
result = validator.isCreditCard('sample');
|
||||
|
||||
validator.isHexadecimal("sample");
|
||||
let isCurrencyOptions: ValidatorJS.IsCurrencyOptions;
|
||||
result = validator.isCurrency('sample');
|
||||
result = validator.isCurrency('sample', isCurrencyOptions);
|
||||
|
||||
validator.isHexColor("sample");
|
||||
result = validator.isDate('sample');
|
||||
|
||||
validator.isLowercase("sample");
|
||||
result = validator.isDecimal('sample');
|
||||
|
||||
validator.isUppercase("sample");
|
||||
result = validator.isDivisibleBy('sample', 2);
|
||||
|
||||
validator.isInt("sample");
|
||||
let isEmailOptions: ValidatorJS.IsEmailOptions;
|
||||
result = validator.isEmail('sample');
|
||||
result = validator.isEmail('sample', isEmailOptions);
|
||||
|
||||
validator.isFloat("sample");
|
||||
let isFQDNOptions: ValidatorJS.IsFQDNOptions;
|
||||
result = validator.isFQDN('sample');
|
||||
result = validator.isFQDN('sample', isFQDNOptions);
|
||||
|
||||
validator.isDivisibleBy("sample", 2);
|
||||
let isFloatOptions: ValidatorJS.IsFloatOptions;
|
||||
result = validator.isFloat('sample');
|
||||
result = validator.isFloat('sample', isFloatOptions);
|
||||
|
||||
validator.isNull("sample");
|
||||
result = validator.isFullWidth('sample');
|
||||
|
||||
validator.isLength("sample", 3, 5);
|
||||
result = validator.isHalfWidth('sample');
|
||||
|
||||
validator.isByteLength("sample", 3);
|
||||
result = validator.isHexColor('sample');
|
||||
|
||||
validator.isUUID("sample");
|
||||
result = validator.isHexadecimal('sample');
|
||||
|
||||
validator.isDate("sample");
|
||||
result = validator.isIP('sample');
|
||||
result = validator.isIP('sample', 6);
|
||||
|
||||
validator.isAfter("sample");
|
||||
result = validator.isISBN('sample');
|
||||
result = validator.isISBN('sample', 13);
|
||||
|
||||
validator.isBefore("sample");
|
||||
result = validator.isISIN('sample');
|
||||
|
||||
validator.isIn("sample", []);
|
||||
result = validator.isISO8601('sample');
|
||||
|
||||
validator.isCreditCard("sample");
|
||||
result = validator.isIn('sample', []);
|
||||
|
||||
validator.isISBN("sample");
|
||||
let isIntOptions: ValidatorJS.IsIntOptions;
|
||||
result = validator.isInt('sample');
|
||||
result = validator.isInt('sample', isIntOptions);
|
||||
|
||||
validator.isJSON("sample");
|
||||
result = validator.isJSON('sample');
|
||||
|
||||
validator.isMultibyte("sample");
|
||||
let isLengthOptions: ValidatorJS.IsLengthOptions;
|
||||
result = validator.isLength('sample', isLengthOptions);
|
||||
result = validator.isLength('sample', 3);
|
||||
result = validator.isLength('sample', 3, 5);
|
||||
|
||||
validator.isAscii("sample");
|
||||
result = validator.isLowercase('sample');
|
||||
|
||||
validator.isFullWidth("sample");
|
||||
result = validator.isMACAddress('sample');
|
||||
|
||||
validator.isHalfWidth("sample");
|
||||
result = validator.isMobilePhone('sample', 'en-US');
|
||||
|
||||
validator.isVariableWidth("sample");
|
||||
result = validator.isMongoId('sample');
|
||||
|
||||
validator.isSurrogatePair("sample");
|
||||
result = validator.isMultibyte('sample');
|
||||
|
||||
validator.isMongoId("sample");
|
||||
result = validator.isNull('sample');
|
||||
|
||||
validator.toString(123);
|
||||
result = validator.isNumeric('sample');
|
||||
|
||||
validator.toDate(1225);
|
||||
result = validator.isSurrogatePair('sample');
|
||||
|
||||
validator.toFloat('011');
|
||||
let isURLOptions: ValidatorJS.IsURLOptions;
|
||||
result = validator.isURL('sample');
|
||||
result = validator.isURL('sample', isURLOptions);
|
||||
|
||||
validator.toInt('aa');
|
||||
result = validator.isUUID('sample');
|
||||
result = validator.isUUID('sample', 5);
|
||||
|
||||
validator.toBoolean('yes!');
|
||||
result = validator.isUppercase('sample');
|
||||
|
||||
validator.trim(' triming ');
|
||||
result = validator.isVariableWidth('sample');
|
||||
|
||||
validator.ltrim(' triming ');
|
||||
result = validator.isWhitelisted('sample', 'abc');
|
||||
result = validator.isWhitelisted('sample', ['a', 'b', 'c']);
|
||||
|
||||
validator.rtrim(' triming ');
|
||||
result = validator.matches('foobar', 'foo/i');
|
||||
result = validator.matches('foobar', 'foo', 'i');
|
||||
}
|
||||
|
||||
validator.escape('<script>');
|
||||
/**************
|
||||
* Sanitizers *
|
||||
**************/
|
||||
|
||||
validator.stripLow('\x7Ffoo\x02');
|
||||
{
|
||||
let result: string;
|
||||
|
||||
validator.whitelist('ab', 'abcdef');
|
||||
result = validator.blacklist('sample', 'abc');
|
||||
|
||||
validator.blacklist('abc', 'abcdef');
|
||||
result = validator.escape('sample');
|
||||
|
||||
validator.normalizeEmail('!');
|
||||
result = validator.ltrim('sample');
|
||||
result = validator.ltrim('sample', ' ');
|
||||
|
||||
let normalizeEmailOptions: ValidatorJS.NormalizeEmailOptions;
|
||||
result = validator.normalizeEmail('sample');
|
||||
result = validator.normalizeEmail('sample', normalizeEmailOptions);
|
||||
|
||||
result = validator.rtrim('sample');
|
||||
result = validator.rtrim('sample', ' ');
|
||||
|
||||
result = validator.stripLow('sample');
|
||||
result = validator.stripLow('sample', true);
|
||||
}
|
||||
|
||||
{
|
||||
let result: boolean;
|
||||
|
||||
result = validator.toBoolean(any);
|
||||
result = validator.toBoolean(any, true);
|
||||
}
|
||||
|
||||
{
|
||||
let result: Date;
|
||||
|
||||
result = validator.toDate(any);
|
||||
}
|
||||
|
||||
{
|
||||
let result: number;
|
||||
|
||||
result = validator.toFloat(any);
|
||||
|
||||
result = validator.toInt(any);
|
||||
result = validator.toInt(any, 10);
|
||||
}
|
||||
|
||||
{
|
||||
let result: string;
|
||||
|
||||
result = validator.toString(any);
|
||||
|
||||
result = validator.trim('sample');
|
||||
result = validator.trim('sample', ' ');
|
||||
|
||||
result = validator.whitelist('sample', 'abc');
|
||||
}
|
||||
|
||||
/**************
|
||||
* Extensions *
|
||||
**************/
|
||||
|
||||
validator.extend<(str: string, options: {}) => boolean>('isTest', (str: any, options: {}) => !str);
|
||||
|
||||
Vendored
+229
-130
@@ -1,193 +1,292 @@
|
||||
// Type definitions for validator.js v3.22.1
|
||||
// Type definitions for validator.js v4.5.1
|
||||
// Project: https://github.com/chriso/validator.js
|
||||
// Definitions by: tgfjt <https://github.com/tgfjt>
|
||||
// Definitions by: tgfjt <https://github.com/tgfjt>, Ilya Mochalov <https://github.com/chrootsu>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// options for #isURL
|
||||
interface IURLoptions {
|
||||
protocols?: string[]
|
||||
require_tld?: boolean
|
||||
require_protocol?: boolean
|
||||
allow_underscores?: boolean
|
||||
}
|
||||
declare namespace ValidatorJS {
|
||||
interface ValidatorStatic {
|
||||
|
||||
// options for isFQDN
|
||||
interface IFQDNoptions {
|
||||
require_tld?: boolean
|
||||
allow_underscores?: boolean
|
||||
}
|
||||
/**************
|
||||
* Validators *
|
||||
**************/
|
||||
|
||||
// options for normalizeEmail
|
||||
interface IEmailoptions {
|
||||
lowercase?: boolean
|
||||
}
|
||||
// check if the string contains the seed.
|
||||
contains(str: string, elem: any): boolean;
|
||||
|
||||
// callback type for #extend
|
||||
interface IExtendCallback {
|
||||
(argv: string): any
|
||||
}
|
||||
// check if the string matches the comparison.
|
||||
equals(str: string, comparison: any): boolean;
|
||||
|
||||
// return function for #extend
|
||||
interface IExtendFunc {
|
||||
(argv: string): boolean
|
||||
}
|
||||
// check if the string is a date that's after the specified date (defaults to now).
|
||||
isAfter(str: string, date?: Date): boolean;
|
||||
|
||||
interface IValidatorStatic {
|
||||
// add your own validators
|
||||
extend(name: string, fn: IExtendCallback): IExtendFunc;
|
||||
// check if the string contains only letters (a-zA-Z).
|
||||
isAlpha(str: string): boolean;
|
||||
|
||||
// check if the string matches the comparison.
|
||||
equals(str: string, comparison: any): boolean;
|
||||
// check if the string contains only letters and numbers.
|
||||
isAlphanumeric(str: string): boolean;
|
||||
|
||||
// check if the string contains the seed.
|
||||
contains(str: string, elem: any): boolean;
|
||||
// check if the string contains ASCII chars only.
|
||||
isAscii(str: string): boolean;
|
||||
|
||||
// check if string matches the pattern.
|
||||
matches(str: string, pattern: any, modifiers?: string): boolean;
|
||||
// check if a string is base64 encoded.
|
||||
isBase64(str: string): boolean;
|
||||
|
||||
// check if the string is an email.
|
||||
isEmail(str: string): boolean;
|
||||
// check if the string is a date that's before the specified date.
|
||||
isBefore(str: string, date?: Date): boolean;
|
||||
|
||||
// check if the string is an URL.
|
||||
isURL(str: string, options?: IURLoptions): boolean;
|
||||
// check if a string is a boolean.
|
||||
isBoolean(str: string): boolean;
|
||||
|
||||
// check if the string is a fully qualified domain name (e.g. domain.com).
|
||||
isFQDN(str: string, options?: IFQDNoptions): boolean;
|
||||
// check if the string's length (in bytes) falls in a range.
|
||||
isByteLength(str: string, options: IsByteLengthOptions): boolean;
|
||||
isByteLength(str: string, min: number, max?: number): boolean;
|
||||
|
||||
// check if the string is a MAC address.
|
||||
isMACAddress(str: string): boolean;
|
||||
// check if the string is a credit card.
|
||||
isCreditCard(str: string): boolean;
|
||||
|
||||
// check if the string is an IP (version 4 or 6).
|
||||
isIP(str: string, version?: number): boolean;
|
||||
// check if the string is a valid currency amount.
|
||||
isCurrency(str: string, options?: IsCurrencyOptions): boolean;
|
||||
|
||||
// check if the string contains only letters (a-zA-Z).
|
||||
isAlpha(str: string): boolean;
|
||||
// check if the string is a date.
|
||||
isDate(str: string): boolean;
|
||||
|
||||
// check if the string contains only numbers.
|
||||
isNumeric(str: string): boolean;
|
||||
// check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc.
|
||||
isDecimal(str: string): boolean;
|
||||
|
||||
// check if the string contains only letters and numbers.
|
||||
isAlphanumeric(str: string): boolean;
|
||||
// check if the string is a number that's divisible by another.
|
||||
isDivisibleBy(str: string, number: number): boolean;
|
||||
|
||||
// check if a string is base64 encoded.
|
||||
isBase64(str: string): boolean;
|
||||
// check if the string is an email.
|
||||
isEmail(str: string, options?: IsEmailOptions): boolean;
|
||||
|
||||
// check if the string is a hexadecimal number.
|
||||
isHexadecimal(str: string): boolean;
|
||||
// check if the string is a fully qualified domain name (e.g. domain.com).
|
||||
isFQDN(str: string, options?: IsFQDNOptions): boolean;
|
||||
|
||||
// check if the string is a hexadecimal color.
|
||||
isHexColor(str: string): boolean;
|
||||
// check if the string is a float.
|
||||
isFloat(str: string, options?: IsFloatOptions): boolean;
|
||||
|
||||
// check if the string is lowercase.
|
||||
isLowercase(str: string): boolean;
|
||||
// check if the string contains any full-width chars.
|
||||
isFullWidth(str: string): boolean;
|
||||
|
||||
// check if the string is uppercase.
|
||||
isUppercase(str: string): boolean;
|
||||
// check if the string contains any half-width chars.
|
||||
isHalfWidth(str: string): boolean;
|
||||
|
||||
// check if the string is an integer.
|
||||
isInt(str: string): boolean;
|
||||
// check if the string is a hexadecimal color.
|
||||
isHexColor(str: string): boolean;
|
||||
|
||||
// check if the string is a float.
|
||||
isFloat(str: string): boolean;
|
||||
// check if the string is a hexadecimal number.
|
||||
isHexadecimal(str: string): boolean;
|
||||
|
||||
// check if the string is a number that's divisible by another.
|
||||
isDivisibleBy(str: string, number: number): boolean;
|
||||
// check if the string is an IP (version 4 or 6).
|
||||
isIP(str: string, version?: number): boolean;
|
||||
|
||||
// check if the string is null.
|
||||
isNull(str: string): boolean;
|
||||
// check if the string is an ISBN (version 10 or 13).
|
||||
isISBN(str: string, version?: number): boolean;
|
||||
|
||||
// check if the string's length falls in a range. Note: this function takes into account surrogate pairs.
|
||||
isLength(str: string, min: number, max?: number): boolean;
|
||||
// check if the string is an ISIN (https://en.wikipedia.org/wiki/International_Securities_Identification_Number)
|
||||
// (stock/security identifier).
|
||||
isISIN(str: string): boolean;
|
||||
|
||||
// check if the string's length (in bytes) falls in a range.
|
||||
isByteLength(str: string, min: number, max?: number): boolean;
|
||||
// check if the string is a valid ISO 8601 (https://en.wikipedia.org/wiki/ISO_8601) date.
|
||||
isISO8601(str: string): boolean;
|
||||
|
||||
// check if the string is a UUID (version 3, 4 or 5).
|
||||
isUUID(str: string, version?: number): boolean;
|
||||
// check if the string is in a array of allowed values.
|
||||
isIn(str: string, values: any[]): boolean;
|
||||
|
||||
// check if the string is a date.
|
||||
isDate(str: string): boolean;
|
||||
// check if the string is an integer.
|
||||
isInt(str: string, options?: IsIntOptions): boolean;
|
||||
|
||||
// check if the string is a date that's after the specified date (defaults to now).
|
||||
isAfter(str: string, date?: Date): boolean;
|
||||
// check if the string is valid JSON (note: uses JSON.parse).
|
||||
isJSON(str: string): boolean;
|
||||
|
||||
// check if the string is a date that's before the specified date.
|
||||
isBefore(str: string, date?: Date): boolean;
|
||||
// check if the string's length falls in a range.
|
||||
// Note: this function takes into account surrogate pairs.
|
||||
isLength(str: string, options: IsLengthOptions): boolean;
|
||||
isLength(str: string, min: number, max?: number): boolean;
|
||||
|
||||
// check if the string is in a array of allowed values.
|
||||
isIn(str: string, values: any[]): boolean;
|
||||
// check if the string is lowercase.
|
||||
isLowercase(str: string): boolean;
|
||||
|
||||
// check if the string is a credit card.
|
||||
isCreditCard(str: string): boolean;
|
||||
// check if the string is a MAC address.
|
||||
isMACAddress(str: string): boolean;
|
||||
|
||||
// check if the string is an ISBN (version 10 or 13).
|
||||
isISBN(str: string, version?: number): boolean;
|
||||
// check if the string is a mobile phone number, (locale is one of ['zh-CN', 'zh-TW', 'en-ZA', 'en-AU', 'en-HK',
|
||||
// 'pt-PT', 'fr-FR', 'el-GR', 'en-GB', 'en-US', 'en-ZM', 'ru-RU', 'nb-NO', 'nn-NO', 'vi-VN', 'en-NZ', 'en-IN']).
|
||||
isMobilePhone(str: string, locale: string): boolean;
|
||||
|
||||
// check if the string is valid JSON (note: uses JSON.parse).
|
||||
isJSON(str: string): boolean;
|
||||
// check if the string is a valid hex-encoded representation of a MongoDB ObjectId
|
||||
// (http://docs.mongodb.org/manual/reference/object-id/).
|
||||
isMongoId(str: string): boolean;
|
||||
|
||||
// check if the string contains one or more multibyte chars.
|
||||
isMultibyte(str: string): boolean;
|
||||
// check if the string contains one or more multibyte chars.
|
||||
isMultibyte(str: string): boolean;
|
||||
|
||||
// check if the string contains ASCII chars only.
|
||||
isAscii(str: string): boolean;
|
||||
// check if the string is null.
|
||||
isNull(str: string): boolean;
|
||||
|
||||
// check if the string contains any full-width chars.
|
||||
isFullWidth(str: string): boolean;
|
||||
// check if the string contains only numbers.
|
||||
isNumeric(str: string): boolean;
|
||||
|
||||
// check if the string contains any half-width chars.
|
||||
isHalfWidth(str: string): boolean;
|
||||
// check if the string contains any surrogate pairs chars.
|
||||
isSurrogatePair(str: string): boolean;
|
||||
|
||||
// check if the string contains a mixture of full and half-width chars.
|
||||
isVariableWidth(str: string): boolean;
|
||||
// check if the string is an URL.
|
||||
isURL(str: string, options?: IsURLOptions): boolean;
|
||||
|
||||
// check if the string contains any surrogate pairs chars.
|
||||
isSurrogatePair(str: string): boolean;
|
||||
// check if the string is a UUID (version 3, 4 or 5).
|
||||
isUUID(str: string, version?: number): boolean;
|
||||
|
||||
// check if the string is a valid hex-encoded representation of a MongoDB ObjectId.
|
||||
isMongoId(str: string): boolean;
|
||||
// check if the string is uppercase.
|
||||
isUppercase(str: string): boolean;
|
||||
|
||||
// convert the input to a string.
|
||||
toString(input: any): string;
|
||||
// check if the string contains a mixture of full and half-width chars.
|
||||
isVariableWidth(str: string): boolean;
|
||||
|
||||
// convert the input to a date, or null if the input is not a date.
|
||||
toDate(input: any): any; // Date or null
|
||||
// checks characters if they appear in the whitelist.
|
||||
isWhitelisted(str: string, chars: string|string[]): boolean;
|
||||
|
||||
// convert the input to a float, or NaN if the input is not a float.
|
||||
toFloat(input:any): number; // number or NaN
|
||||
// check if string matches the pattern.
|
||||
matches(str: string, pattern: any, modifiers?: string): boolean;
|
||||
|
||||
// convert the input to an integer, or NaN if the input is not an integer.
|
||||
toInt(input:any, radix?: number): number; // number or NaN
|
||||
/**************
|
||||
* Sanitizers *
|
||||
**************/
|
||||
|
||||
// convert the input to a boolean.
|
||||
toBoolean(input:any, strict?: boolean): boolean;
|
||||
// remove characters that appear in the blacklist. The characters are used in a RegExp and so you will need
|
||||
// to escape some chars, e.g. blacklist(input, '\\[\\]').
|
||||
blacklist(input: string, chars: string): string;
|
||||
|
||||
// trim characters (whitespace by default) from both sides of the input.
|
||||
trim(input: any, chars?: string): string;
|
||||
// replace <, >, &, ', " and / with HTML entities.
|
||||
escape(input: string): string;
|
||||
|
||||
// trim characters from the left-side of the input.
|
||||
ltrim(input: any, chars?: string): string;
|
||||
// trim characters from the left-side of the input.
|
||||
ltrim(input: any, chars?: string): string;
|
||||
|
||||
// trim characters from the right-side of the input.
|
||||
rtrim(input: any, chars?: string): string;
|
||||
// canonicalize an email address.
|
||||
normalizeEmail(email: string, options?: NormalizeEmailOptions): string;
|
||||
|
||||
// replace <, >, &, ' and " with HTML entities.
|
||||
escape(input: string): string;
|
||||
// trim characters from the right-side of the input.
|
||||
rtrim(input: any, chars?: string): string;
|
||||
|
||||
// remove characters with a numerical value < 32 and 127
|
||||
stripLow(input: string, keep_new_lines?: boolean): string;
|
||||
// remove characters with a numerical value < 32 and 127, mostly control characters. If keep_new_lines is true,
|
||||
// newline characters are preserved (\n and \r, hex 0xA and 0xD). Unicode-safe in JavaScript.
|
||||
stripLow(input: string, keep_new_lines?: boolean): string;
|
||||
|
||||
// remove characters that do not appear in the whitelist.
|
||||
whitelist(input: string, chars: string): string;
|
||||
// convert the input to a boolean. Everything except for '0', 'false' and '' returns true. In strict mode only '1'
|
||||
// and 'true' return true.
|
||||
toBoolean(input: any, strict?: boolean): boolean;
|
||||
|
||||
// remove characters that appear in the blacklist.
|
||||
blacklist(input: string, chars: string): string;
|
||||
// convert the input to a date, or null if the input is not a date.
|
||||
toDate(input: any): Date; // Date or null
|
||||
|
||||
// canonicalize an email address.
|
||||
normalizeEmail(email: string, options?: IEmailoptions): string;
|
||||
// convert the input to a float, or NaN if the input is not a float.
|
||||
toFloat(input: any): number; // number or NaN
|
||||
|
||||
// convert the input to an integer, or NaN if the input is not an integer.
|
||||
toInt(input: any, radix?: number): number; // number or NaN
|
||||
|
||||
// convert the input to a string.
|
||||
toString(input: any): string;
|
||||
|
||||
// trim characters (whitespace by default) from both sides of the input.
|
||||
trim(input: any, chars?: string): string;
|
||||
|
||||
// remove characters that do not appear in the whitelist. The characters are used in a RegExp and so you will
|
||||
// need to escape some chars, e.g. whitelist(input, '\\[\\]').
|
||||
whitelist(input: string, chars: string): string;
|
||||
|
||||
/**************
|
||||
* Extensions *
|
||||
**************/
|
||||
|
||||
// add your own validators.
|
||||
// Note: that the first argument will be automatically coerced to a string.
|
||||
extend<T extends Function>(name: string, fn: T): void;
|
||||
}
|
||||
|
||||
// options for IsByteLength
|
||||
interface IsByteLengthOptions {
|
||||
min?: number;
|
||||
max?: number;
|
||||
}
|
||||
|
||||
// options for IsCurrency
|
||||
interface IsCurrencyOptions {
|
||||
symbol?: string;
|
||||
require_symbol?: boolean;
|
||||
allow_space_after_symbol?: boolean;
|
||||
symbol_after_digits?: boolean;
|
||||
allow_negatives?: boolean;
|
||||
parens_for_negatives?: boolean;
|
||||
negative_sign_before_digits?: boolean;
|
||||
negative_sign_after_digits?: boolean;
|
||||
allow_negative_sign_placeholder?: boolean;
|
||||
thousands_separator?: string;
|
||||
decimal_separator?: string;
|
||||
allow_space_after_digits?: boolean;
|
||||
}
|
||||
|
||||
// options for isEmail
|
||||
interface IsEmailOptions {
|
||||
allow_display_name?: boolean;
|
||||
allow_utf8_local_part?: boolean;
|
||||
require_tld?: boolean;
|
||||
}
|
||||
|
||||
// options for isFQDN
|
||||
interface IsFQDNOptions {
|
||||
require_tld?: boolean;
|
||||
allow_underscores?: boolean;
|
||||
allow_trailing_dot?: boolean;
|
||||
}
|
||||
|
||||
// options for IsFloat
|
||||
interface IsFloatOptions {
|
||||
min?: number;
|
||||
max?: number;
|
||||
}
|
||||
|
||||
// options for IsInt
|
||||
interface IsIntOptions {
|
||||
min?: number;
|
||||
max?: number;
|
||||
}
|
||||
|
||||
// options for IsLength
|
||||
interface IsLengthOptions {
|
||||
min?: number;
|
||||
max?: number;
|
||||
}
|
||||
|
||||
// options for isURL
|
||||
interface IsURLOptions {
|
||||
protocols?: string[];
|
||||
require_tld?: boolean;
|
||||
require_protocol?: boolean;
|
||||
require_valid_protocol?: boolean;
|
||||
allow_underscores?: boolean;
|
||||
host_whitelist?: boolean;
|
||||
host_blacklist?: boolean;
|
||||
allow_trailing_dot?: boolean;
|
||||
allow_protocol_relative_urls?: boolean;
|
||||
}
|
||||
|
||||
// options for normalizeEmail
|
||||
interface NormalizeEmailOptions {
|
||||
lowercase?: boolean;
|
||||
remove_dots?: boolean;
|
||||
remove_extension?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "validator" {
|
||||
var validator: IValidatorStatic;
|
||||
let validator: ValidatorJS.ValidatorStatic;
|
||||
namespace validator {}
|
||||
export = validator;
|
||||
}
|
||||
|
||||
// deprecated interfaces for backward compatibility, please use ValidatorJS.* instead the ones
|
||||
interface IValidatorStatic extends ValidatorJS.ValidatorStatic {}
|
||||
interface IURLoptions extends ValidatorJS.IsURLOptions {}
|
||||
interface IFQDNoptions extends ValidatorJS.IsFQDNOptions {}
|
||||
interface IEmailoptions extends ValidatorJS.NormalizeEmailOptions {}
|
||||
|
||||
Reference in New Issue
Block a user