check if the string is a valid RFC 3339 date. https://tools.ietf.org/html/rfc3339
Check if the input is a valid date.
The string to validate
Check if the input is a valid ISO8601 date.
The string to validate
Check if the input is a valid ISO8601 Duration string. For a discussion of this format see https://en.wikipedia.org/wiki/ISO_8601#Durations For example, "P3Y6M4DT12H30M5S" represents a duration of "three years, six months, four days, twelve hours, thirty minutes, and five seconds".
The string to validate
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 valid ISO 4217 officially assigned currency code.
Check if the given value is a valid Tax Identification Number.
For precise info about exact TIN support, consult the parent
validator.js
package source code.
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 an International Standard Recording Code (ISRC). https://en.wikipedia.org/wiki/International_Standard_Recording_Code
Check if the string is valid JWT token.
check if the string is a MD5 hash. Equivalent to isHash(value, 'md5')
.
check if the string is a magnet uri format. https://en.wikipedia.org/wiki/Magnet_URI_scheme
check if the string matches to a valid MIME type format https://en.wikipedia.org/wiki/Media_type
check if the string is a valid port number.
Check if the string is of type slug. Options allow a single hyphen between string. e.g. [cn-cn, cn-c-c]
check if the string is a hash of type algorithm.
check if the string is a MAC address.
The string to validate
check if the string is a rgb or rgba color.
The string to validate
check if the string is an URL.
The string to validate
check if the string is a UUID (version 1, 2, 3, 4 or 5).
The string to validate
check if the string is a valid octal number.
check if the string contains only numbers.
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 lowercase.
check if the string contains one or more multibyte chars.
check if the string contains any surrogate pairs chars.
check if the string is uppercase.
check if the string contains a mixture of full and half-width chars.
Check if the string is valid JSON (note: uses JSON.parse).
check if the string's length falls in a range.
checks characters if they appear in the whitelist.
check if string matches the pattern.
Either matches('foo', /foo/i)
or matches('foo', 'foo', 'i')
.
check if the string is an ISIN (stock/security identifier).
check if the string is a locale
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 is a Semantic Versioning Specification (SemVer).
check if the string is a valid latitude-longitude coordinate
in the format lat,long
or lat, long
.
check if string matches the format of a country's license plate.
check if the string is a mobile phone number,
check if the string is a valid passport number.
check if the string is a postal code,
Check if a password is strong or not. Allows for custom requirements or scoring rules. If returnScore is true, then the function returns an integer score for the password rather than a boolean.
checks that the string is a valid VAT number if validation is available for the given country code matching ISO 3166-1 alpha-2.
These are the validation functions for the
runtime-data-validation
package. These functions all take as their first parameter a value, as astring
, that is to be validated. Any additional parameters provide configuration to customize the validation.These functions can serve as type guard functions. In other words, at the beginning of a function it is good form to validate the parameters. If your function is part of a class its parameters can be validated using decorators. But a standalone function cannot be instrumented with decorators, in which case you can directly use these functions.
USAGE:
Return to home page