Skip to main content
Module

x/leaves/mod.ts

A Web framework For Deno with Decorator and middleware
Latest
import * as leaves from "https://deno.land/x/leaves@v0.1.5/mod.ts";

Classes

Dependency Container

Storage all metadatas.

Validation error description.

Validation types.

Validator performs validation of the given object based on its metadata.

Enums

Enum representing the different transformation types.

Variables

Functions

Class decorator factory that replaces the decorated class' constructor with a parameter less constructor that has dependencies auto-resolved

Parameter decorator factory that allows for interface information to be stored in the constructor's metadata

Class decorator factory that allows the class' dependencies to be injected at runtime.

Parameter decorator factory that allows for interface information to be stored in the constructor's metadata

Class decorator factory that allows constructor dependencies to be registered at runtime.

Class decorator factory that registers the class as a scoped dependency within the global container.

Class decorator factory that registers the class as a singleton within the global container.

Converts class (constructor) object to new class (constructor) object. Also works with arrays.

Converts class (constructor) object to plain (literal) object. Uses given plain object as source object (it means fills given plain object with data from class object). Also works with arrays.

Converts class (constructor) object to plain (literal) object. Also works with arrays.

Converts class (constructor) object to plain (literal) object. Uses given plain object as source object (it means fills given plain object with data from class object). Also works with arrays.

Deserializes given JSON string to a object of the given class.

Deserializes given JSON string to an array of objects of the given class.

Marks property as excluded from the process of transformation. By default it excludes the property for both constructorToPlain and plainToConstructor transformations, however you can specify on which of transformation types you want to skip this property.

Marks property as included in the process of transformation. By default it includes the property for both constructorToPlain and plainToConstructor transformations, however you can specify on which of transformation types you want to skip this property.

Converts plain (literal) object to class (constructor) object. Also works with arrays.

Converts plain (literal) object to class (constructor) object. Uses given object as source object (it means fills given object with data from plain object). Also works with arrays.

Serializes given object to a JSON string.

Defines a custom logic for value transformation.

Return the class instance only with the exposed properties.

Transform the object from class to plain object and return only with the exposed properties.

Return the class instance only with the exposed properties.

Specifies a type of the property. The given TypeFunction can return a constructor. A discriminator can be given in the options.

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 array's length is as maximal this number. If null or undefined is given then this function returns false.

Checks if array's length is as maximal this number. If null or undefined is given then this function returns false.

Checks if array's length is as minimal this number. If null or undefined is given then this function returns false.

Checks if array's length is as minimal this 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.

Gets the IOC container used by this library.

Gets metadata storage. Metadata storage follows the best practices and stores metadata in a global variable.

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 number.

Checks if a value is a number.

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 number.

Checks if a value is a number.

Checks if a given value is a ISOString date.

Checks if a given value is a ISOString date.

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.

Checks if the string is a valid phone number.

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.

Registers a custom validation decorator.

Registers a new validation schema.

Sets container to be used by this library.

Validates given object.

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

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

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

Validates given object and reject on error.

Resolve promise before validation

Performs sync validation of the given object. Note that this method completely ignores async validations. If you want to properly perform validation you need to call validate method instead.

Registers custom validator class.

Interfaces

Provide a dependency using a factory. Unlike the other providers, this does not support instance caching. If you need instance caching, your factory method must implement it.

Options to be passed during transformation.

Options to be passed to IsNumber decorator.

Container options.

Arguments being sent to message builders - user can create message either by simply returning a string, either by returning a function that accepts MessageArguments and returns a message string built based on these arguments.

Options used to pass to validation decorators.

Validation schema is a decorator-free way of validation of your objects. Also using validation schemas makes this library to be easily used with es6/es5.

Custom validators must implement this interface to provide custom validation logic.

Options passed to validator during validation.