Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno_class_validator/src/decorator/decorators.ts

Decorator-based property validation for classes.
Latest
import * as denoClassValidator from "https://deno.land/x/deno_class_validator@v1.0.0/src/decorator/decorators.ts";

Variables

Functions

If object has both allowed and not allowed properties a validation error will be thrown.

Checks if array contains all values from the given array of values. If null or undefined is given then this function returns false.

Checks if array contains all values from the given array of values. If null or undefined is given then this function returns false.

Checks if the array's length is less or equal to the specified number. If null or undefined is given then this function returns false.

Checks if the array's length is less or equal to the specified number. If null or undefined is given then this function returns false.

Checks if the array's length is greater than or equal to the specified number. If null or undefined is given then this function returns false.

Checks if the array's length is greater than or equal to the specified number. If null or undefined is given then this function returns false.

Checks if array does not contain any of the given values. If null or undefined is given then this function returns false.

Checks if array does not contain any of the given values. If null or undefined is given then this function returns false.

Checks if given array is not empty. If null or undefined is given then this function returns false.

Checks if given array is not empty. If null or undefined is given then this function returns false.

Checks if all array's values are unique. Comparison for objects is reference-based. If null or undefined is given then this function returns false.

Checks if all array's values are unique. Comparison for objects is reference-based. If null or undefined is given then this function returns false.

Checks if the string contains the seed. If given value is not a string, then it returns false.

Checks if the string contains the seed. If given value is not a string, then it returns false.

Checks if value matches ("===") the comparison.

Checks if value matches ("===") the comparison.

Checks if the string contains only letters (a-zA-Z). If given value is not a string, then it returns false.

Checks if the string contains only letters (a-zA-Z). If given value is not a string, then it returns false.

Checks if the string contains only letters and numbers. If given value is not a string, then it returns false.

Checks if the string contains only letters and numbers. If given value is not a string, then it returns false.

Checks if a given value is an array

Checks if a given value is an array

Checks if the string contains ASCII chars only. If given value is not a string, then it returns false.

Checks if the string contains ASCII chars only. If given value is not a string, then it returns false.

Checks if a string is base32 encoded. If given value is not a string, then it returns false.

Check if a string is base32 encoded. If given value is not a string, then it returns false.

Checks if a string is base64 encoded. If given value is not a string, then it returns false.

Checks if a string is base64 encoded. If given value is not a string, then it returns false.

Check if a string is a BIC (Bank Identification Code) or SWIFT code. If given value is not a string, then it returns false.

Check if a string is a BIC (Bank Identification Code) or SWIFT code. If given value is not a string, then it returns false.

Checks if a given value is a boolean.

Checks if a value is a boolean.

Checks if a string is a boolean. If given value is not a string, then it returns false.

Checks if a string is a boolean. If given value is not a string, then it returns false.

Check if the string is a valid BTC address. If given value is not a string, then it returns false.

Check if the string is a valid BTC address. If given value is not a string, then it returns false.

Checks if the string's length (in bytes) falls in a range. If given value is not a string, then it returns false.

Checks if the string's length (in bytes) falls in a range. If given value is not a string, then it returns false.

Checks if the string is a credit card. If given value is not a string, then it returns false.

Checks if the string is a credit card. If given value is not a string, then it returns false.

Checks if the string is a valid currency amount. If given value is not a string, then it returns false.

Checks if the string is a valid currency amount. If given value is not a string, then it returns false.

Check if the string is a data uri format. If given value is not a string, then it returns false.

Check if the string is a data uri format. If given value is not a string, then it returns false.

Checks if a given value is a date.

Checks if a value is a date.

Alias for IsISO8601 validator

Alias for IsISO8601 validator

Checks if the string is a valid decimal. If given value is not a string, then it returns false.

Checks if the string contains only letters and numbers. If given value is not a string, then it returns false.

Checks if value is defined (!== undefined, !== null).

Checks if value is defined (!== undefined, !== null).

Checks if value is a number that's divisible by another.

Checks if value is a number that's divisible by another.

Check if the string is an EAN (European Article Number). If given value is not a string, then it returns false.

Check if the string is an EAN (European Article Number). If given value is not a string, then it returns false.

Checks if the string is an email. If given value is not a string, then it returns false.

Checks if the string is an email. If given value is not a string, then it returns false.

Checks if given value is empty (=== '', === null, === undefined).

Checks if given value is empty (=== '', === null, === undefined).

Checks if a given value is an enum

Checks if a given value is an enum

Check if the string is an Ethereum address using basic regex. Does not validate address checksums. If given value is not a string, then it returns false.

Check if the string is an Ethereum address using basic regex. Does not validate address checksums. If given value is not a string, then it returns false.

Checks if the string is a Firebase Push Id If given value is not a Firebase Push Id, it returns false

Checks if the string is a Firebase Push Id If given value is not a Firebase Push Id, it returns false

Checks if the string is a fully qualified domain name (e.g. domain.com). If given value is not a string, then it returns false.

Checks if the string is a fully qualified domain name (e.g. domain.com). If given value is not a string, then it returns false.

Checks if the string contains any full-width chars. If given value is not a string, then it returns false.

Checks if the string contains any full-width chars. If given value is not a string, then it returns false.

Checks if the string contains any half-width chars. If given value is not a string, then it returns false.

Checks if the string contains any full-width chars. If given value is not a string, then it returns false.

Check if the string is a hash of type algorithm. Algorithm is one of ['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']

Check if the string is a hash of type algorithm. Algorithm is one of ['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']

Checks if the string is a hexadecimal number. If given value is not a string, then it returns false.

Checks if the string is a hexadecimal number. If given value is not a string, then it returns false.

Checks if the string is a hexadecimal color. If given value is not a string, then it returns false.

Checks if the string is a hexadecimal color. If given value is not a string, then it returns false.

Check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on CSS Colors Level 4 specification. Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: hsl(200grad+.1%62%/1)). If given value is not a string, then it returns false.

Check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on CSS Colors Level 4 specification. Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: hsl(200grad+.1%62%/1)). If given value is not a string, then it returns false.

Check if a string is a IBAN (International Bank Account Number). If given value is not a string, then it returns false.

Check if a string is a IBAN (International Bank Account Number). If given value is not a string, then it returns false.

Check if the string is a valid identity card code. locale is one of ['ES', 'zh-TW', 'he-IL', 'ar-TN'] OR 'any'. If 'any' is used, function will check if any of the locals match. Defaults to 'any'. If given value is not a string, then it returns false.

Check if the string is a valid identity card code. locale is one of ['ES', 'zh-TW', 'he-IL', 'ar-TN'] OR 'any'. If 'any' is used, function will check if any of the locals match. Defaults to 'any'. If given value is not a string, then it returns false.

Checks if given value is in a array of allowed values.

Checks if given value is in a array of allowed values.

Checks if the value is an instance of the specified object.

Checks if the value is an instance of the specified object.

Checks if value is an integer.

Checks if value is an integer.

Checks if the string is an IP (version 4 or 6). If given value is not a string, then it returns false.

Checks if the string is an IP (version 4 or 6). If given value is not a string, then it returns false.

Checks if the string is an ISBN (version 10 or 13). If given value is not a string, then it returns false.

Checks if the string is an ISBN (version 10 or 13). If given value is not a string, then it returns false.

Checks if the string is an ISIN (stock/security identifier). If given value is not a string, then it returns false.

Checks if the string is an ISIN (stock/security identifier). If given value is not a string, then it returns false.

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-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 3166-1 alpha-3 officially assigned country code.

Checks if the string is a valid ISO 8601 date. If given value is not a string, then it returns false. Use the option strict = true for additional checks for a valid date, e.g. invalidates dates like 2019-02-29.

Checks if the string is a valid ISO 8601 date. If given value is not a string, then it returns false. Use the option strict = true for additional checks for a valid date, e.g. invalidates dates like 2019-02-29.

Check if the string is a ISRC. If given value is not a string, then it returns false.

Check if the string is a ISRC. If given value is not a string, then it returns false.

Checks if the string is a ISSN. If given value is not a string, then it returns false.

Checks if the string is a ISSN. If given value is not a string, then it returns false.

Checks if the string is valid JSON (note: uses JSON.parse). If given value is not a string, then it returns false.

Checks if the string is valid JSON (note: uses JSON.parse). If given value is not a string, then it returns false.

Checks if the string is valid JWT token. If given value is not a string, then it returns false.

Checks if the string is valid JWT token. If given value is not a string, then it returns false.

Checks if a given value is a latitude.

Checks if a given value is a latitude.

Checks if a value is string in format a "latitude,longitude".

Checks if a value is string in format a "latitude,longitude".

Check if the string is a locale. If given value is not a string, then it returns false.

Check if the string is a locale. If given value is not a string, then it returns false.

Checks if a given value is a longitude.

Checks if a given value is a longitude.

Checks if the string is lowercase. If given value is not a string, then it returns false.

Checks if the string is lowercase. If given value is not a string, then it returns false.

Check if the string is a MAC address. If given value is not a string, then it returns false.

Check if the string is a MAC address. If given value is not a string, then it returns false.

Check if the string is a magnet uri format. If given value is not a string, then it returns false.

Check if the string is a magnet uri format. If given value is not a string, then it returns false.

Checks if the string represents a time without a given timezone in the format HH:MM (military) If the given value does not match the pattern HH:MM, then it returns false.

Checks if the string represents a time without a given timezone in the format HH:MM (military) If the given value does not match the pattern HH:MM, then it returns false.

Check if the string matches to a valid MIME type format If given value is not a string, then it returns false.

Check if the string matches to a valid MIME type format If given value is not a string, then it returns false.

Checks if the string is a mobile phone number (locale is either an array of locales (e.g ['sk-SK', 'sr-RS']) OR one of ['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'be-BY', 'bg-BG', 'bn-BD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'es-CL', 'es-CR', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'ja-JP', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW'] If given value is not a string, then it returns false.

Checks if the string is a mobile phone number (locale is either an array of locales (e.g ['sk-SK', 'sr-RS']) OR one of ['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'be-BY', 'bg-BG', 'bn-BD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'es-CL', 'es-CR', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'ja-JP', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW'] If given value is not a string, then it returns false.

Checks if the string is a valid hex-encoded representation of a MongoDB ObjectId. If given value is not a string, then it returns false.

Checks if the string is a valid hex-encoded representation of a MongoDB ObjectId. If given value is not a string, then it returns false.

Checks if the string contains one or more multibyte chars. If given value is not a string, then it returns false.

Checks if the string contains one or more multibyte chars. If given value is not a string, then it returns false.

Checks if the value is a negative number smaller than zero.

Checks if the value is a negative number smaller than zero.

Checks if given value is not empty (!== '', !== null, !== undefined).

Checks if given value is not empty (!== '', !== null, !== undefined).

Checks if the value is valid Object & not empty. Returns false if the value is not an object or an empty valid object.

Checks if the value is valid Object & not empty. Returns false if the value is not an object or an empty valid object.

Checks if given value not in a array of allowed values.

Checks if given value not in a array of allowed values.

Checks if a given value is a number.

Checks if a value is a number.

Checks if the string is numeric. If given value is not a string, then it returns false.

Checks if the string is numeric. If given value is not a string, then it returns false.

Checks if the value is valid Object. Returns false if the value is not an object.

Checks if the value is valid Object. Returns false if the value is not an object.

Check if the string is a valid octal number. If given value is not a string, then it returns false.

Check if the string is a valid octal number. If given value is not a string, then it returns false.

Checks if value is missing and if so, ignores all validators.

Check if the string is a valid passport number relative to a specific country code. If given value is not a string, then it returns false.

Check if the string is a valid passport number relative to a specific country code. If given value is not a string, then it returns false.

Checks if the string is a valid phone number. To successfully validate any phone number the text must include the intl. calling code, if the calling code wont be provided then the region must be set.

Checks if the string is a valid phone number. To successfully validate any phone number the text must include the intl. calling code, if the calling code wont be provided then the region must be set.

Check if the string is a valid port number.

Check if the string is a valid port number.

Checks if the value is a positive number greater than zero.

Checks if the value is a positive number greater than zero.

Check if the string is a postal code, (locale is one of [ 'AD', 'AT', 'AU', 'BE', 'BG', 'BR', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'NL', 'NO', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SI', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ] OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is validator.isPostalCodeLocales.). If given value is not a string, then it returns false.

Check if the string is a postal code, (locale is one of [ 'AD', 'AT', 'AU', 'BE', 'BG', 'BR', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'NL', 'NO', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SI', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ] OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is validator.isPostalCodeLocales.). If given value is not a string, then it returns false.

Check if the string is a valid RFC 3339 date. If given value is not a string, then it returns false.

Check if the string is a valid RFC 3339 date. If given value is not a string, then it returns false.

Check if the string is a rgb or rgba color. includePercentValues defaults to 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. If given value is not a string, then it returns false.

Check if the string is a rgb or rgba color. includePercentValues defaults to 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. If given value is not a string, then it returns false.

Check if the string is a Semantic Versioning Specification (SemVer). If given value is not a string, then it returns false.

Check if the string is a Semantic Versioning Specification (SemVer). If given value is not a string, then it returns false.

Checks if a given value is a real string.

Checks if a given value is a real string.

Checks if the string contains any surrogate pairs chars. If given value is not a string, then it returns false.

Checks if the string contains any surrogate pairs chars. If given value is not a string, then it returns false.

Checks if the string is uppercase. If given value is not a string, then it returns false.

Checks if the string is uppercase. If given value is not a string, then it returns false.

Checks if the string is an url. If given value is not a string, then it returns false.

Checks if the string is an url. If given value is not a string, then it returns false.

Checks if the string is a UUID (version 3, 4 or 5). If given value is not a string, then it returns false.

Checks if the string is a UUID (version 3, 4 or 5). If given value is not a string, then it returns false.

Checks if the string contains variable-width chars. If given value is not a string, then it returns false.

Checks if the string contains variable-width chars. If given value is not a string, then it returns false.

Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs. If given value is not a string, then it returns false.

Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs. If given value is not a string, then it returns false.

Checks if string matches the pattern. Either matches('foo', /foo/i). If given value is not a string, then it returns false.

Checks if string matches the pattern. Either matches('foo', /foo/i) If given value is not a string, then it returns false.

Checks if the first number is less than or equal to the second.

Checks if the first number is less than or equal to the second.

Checks if the value is a date that's before the specified date.

Checks if the value is a date that's after the specified date.

Checks if the string's length is not more than given number. Note: this function takes into account surrogate pairs. If given value is not a string, then it returns false.

Checks if the string's length is not more than given number. Note: this function takes into account surrogate pairs. If given value is not a string, then it returns false.

Checks if the first number is greater than or equal to the second.

Checks if the first number is greater than or equal to the second.

Checks if the value is a date that's after the specified date.

Checks if the value is a date that's after the specified date.

Checks if the string's length is not less than given number. Note: this function takes into account surrogate pairs. If given value is not a string, then it returns false.

Checks if the string's length is not less than given number. Note: this function takes into account surrogate pairs. If given value is not a string, then it returns false.

Checks if the string does not contain the seed. If given value is not a string, then it returns false.

Checks if the string does not contain the seed. If given value is not a string, then it returns false.

Checks if value does not match ("!==") the comparison.

Checks if value does not match ("!==") the comparison.

Performs validation based on the given custom validation class. Validation class must be decorated with ValidatorConstraint decorator.

Ignores the other validators on a property when the provided condition function returns false.

Objects / object arrays marked with this decorator will also be validated.

Resolve promise before validation

Registers custom validator class.

Interfaces

Options to be passed to IsNumber decorator.