Check if the string is a valid BTC address.
Check if the string is an Ethereum address using basic regex. Does not validate address checksums.
check if the string is a hash of type algorithm.
Check if the string is a valid ISO 3166-1 alpha-2 officially assigned country code.
Check if the string is a valid ISO 3166-1 alpha-3 officially assigned country code.
Check if the string is a valid ISO 4217 officially assigned currency code.
Check if the string is a valid ISO 8601 date.
Check if the string is an International Standard Recording Code (ISRC). https://en.wikipedia.org/wiki/International_Standard_Recording_Code
Check if the string is an International Standard Serial Number (ISSN). https://en.wikipedia.org/wiki/International_Standard_Serial_Number
Check if the string is valid JWT token.
check if the string is a valid latitude-longitude coordinate
in the format lat,long
or lat, long
.
check if the string's length falls in a range.
check if string matches the format of a country's license plate.
check if the string is a locale
check if the string is lowercase.
check if the string is a hash of type algorithm.
Check if the string is valid JWT token.
check if the string matches to a valid MIME type format https://en.wikipedia.org/wiki/Media_type
check if the string is a mobile phone number,
check if the string is a valid hex-encoded representation of a MongoDB ObjectId. http://docs.mongodb.org/manual/reference/object-id/
check if the string contains one or more multibyte chars.
check if the string contains only numbers.
check if the string is a valid octal number.
check if the string is a valid passport number.
check if the string is a valid port number.
check if the string is a valid RFC 3339 date. https://tools.ietf.org/html/rfc3339
check if the string is a rgb or rgba color.
check if the string is a Semantic Versioning Specification (SemVer).
Check if the string is of type slug.
Check if a password is strong or not.
Allows for custom requirements or scoring rules.
The returnScore
option is silently ignored because it is not
compatible with a validation decorator.
check if the string contains any surrogate pairs chars.
Check if the given value is a valid Tax Identification Number. Default locale is en-US.
check if the string is an URL.
check if the string is a UUID (version 1, 2, 3, 4 or 5).
check if the string is uppercase.
checks that the string is a valid VAT number if validation is available for the given country code matching ISO 3166-1 alpha-2.
check if the string contains a mixture of full and half-width chars.
checks characters if they appear in the whitelist.
check if string matches the pattern.
Either matches('foo', /foo/i)
or matches('foo', 'foo', 'i')
.
Generates either an accessor validation decorator function,
or parameter validation decorator function, depending on
the context in which it is being used. The validator
parameter
must be a function for data validation, which returns true
if
the data is valid, or false
otherwise. The function data is
stored in reflection metadata, which is used by
ValidateAccessor or ValidateParams to drive
the validation process.
The validation function
The error message to use in thrown exceptions
An accessor decorator function which performs data validation according to the validation decorators attached to the accessor.
A method decorator function which performs data validation according to the validation decorators attached to any method parameters.
Check if the string is a valid ISO 8601 Duration string.
Allows an application to disable validation. For example, the package
can be enabled during testing and development, and disabled for
production use. By default the package is enabled
, meaning an
internal flag variable is set to true
. To disable, call this
function with false
.
This can be called as desired to enable or disable dynamically. The effect is for the override functions to fall straight through to calling the original function. This means the override functions are still installed, but will have no effect.
Change whether the package is enabled
These are the validation decorators for the
runtime-data-validation
package. The functions in this module are actually decorators, but the documentation is unable to present them as decorators.For the functions we've categorized as decorators, the API will be described something like this:
This is the
@IsAlpha()
decorator. This decorator takes two ptional parameters, locale and options. Any parameters shown are where you should focus your attention. The return type shown here is the decorator function, which you should ignore since it is an implementation detail of TypeScript decorators.In other words, the usage is:
In other words, coding this as a decorator we use
@DecoratorName()
and do not pay attention to the decorator function return value.Return to home page