This commit is contained in:
Pipi Chen
2020-05-07 01:02:44 +08:00
commit b8a3516cd6
2147 changed files with 184854 additions and 0 deletions

1010
node_modules/class-validator/README.md generated vendored Normal file

File diff suppressed because it is too large Load Diff

3197
node_modules/class-validator/bundles/index.esm.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

3582
node_modules/class-validator/bundles/index.umd.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

47
node_modules/class-validator/esm2015/container.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
/**
* Container to be used by this library for inversion control. If container was not implicitly set then by default
* container simply creates a new instance of the given class.
*/
const defaultContainer = new (class {
constructor() {
this.instances = [];
}
get(someClass) {
let instance = this.instances.find(instance => instance.type === someClass);
if (!instance) {
instance = { type: someClass, object: new someClass() };
this.instances.push(instance);
}
return instance.object;
}
})();
let userContainer;
let userContainerOptions;
/**
* Sets container to be used by this library.
*/
export function useContainer(iocContainer, options) {
userContainer = iocContainer;
userContainerOptions = options;
}
/**
* Gets the IOC container used by this library.
*/
export function getFromContainer(someClass) {
if (userContainer) {
try {
const instance = userContainer.get(someClass);
if (instance)
return instance;
if (!userContainerOptions || !userContainerOptions.fallback)
return instance;
}
catch (error) {
if (!userContainerOptions || !userContainerOptions.fallbackOnErrors)
throw error;
}
}
return defaultContainer.get(someClass);
}
//# sourceMappingURL=container.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/container.ts"],"names":[],"mappings":"AAkBA;;;GAGG;AACH,MAAM,gBAAgB,GAAmE,IAAI,CAAC;IAAA;QAClF,cAAS,GAAsC,EAAE,CAAC;IAU9D,CAAC;IATG,GAAG,CAAI,SAAsC;QACzC,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QAC5E,IAAI,CAAC,QAAQ,EAAE;YACX,QAAQ,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,SAAS,EAAE,EAAE,CAAC;YACxD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACjC;QAED,OAAO,QAAQ,CAAC,MAAM,CAAC;IAC3B,CAAC;CACJ,CAAC,EAAE,CAAC;AAEL,IAAI,aAA6E,CAAC;AAClF,IAAI,oBAAyC,CAAC;AAE9C;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,YAA0C,EAAE,OAA6B;IAClG,aAAa,GAAG,YAAY,CAAC;IAC7B,oBAAoB,GAAG,OAAO,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAI,SAA+C;IAC/E,IAAI,aAAa,EAAE;QACf,IAAI;YACA,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC9C,IAAI,QAAQ;gBACR,OAAO,QAAQ,CAAC;YAEpB,IAAI,CAAC,oBAAoB,IAAI,CAAC,oBAAoB,CAAC,QAAQ;gBACvD,OAAO,QAAQ,CAAC;SAEvB;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,CAAC,oBAAoB,IAAI,CAAC,oBAAoB,CAAC,gBAAgB;gBAC/D,MAAM,KAAK,CAAC;SACnB;KACJ;IACD,OAAO,gBAAgB,CAAC,GAAG,CAAI,SAAS,CAAC,CAAC;AAC9C,CAAC","file":"container.js","sourcesContent":["\n/**\n * Container options.\n */\nexport interface UseContainerOptions {\n\n /**\n * If set to true, then default container will be used in the case if given container haven't returned anything.\n */\n fallback?: boolean;\n\n /**\n * If set to true, then default container will be used in the case if given container thrown an exception.\n */\n fallbackOnErrors?: boolean;\n\n}\n\n/**\n * Container to be used by this library for inversion control. If container was not implicitly set then by default\n * container simply creates a new instance of the given class.\n */\nconst defaultContainer: { get<T>(someClass: { new (...args: any[]): T }|Function): T } = new (class {\n private instances: { type: Function, object: any }[] = [];\n get<T>(someClass: { new (...args: any[]): T }): T {\n let instance = this.instances.find(instance => instance.type === someClass);\n if (!instance) {\n instance = { type: someClass, object: new someClass() };\n this.instances.push(instance);\n }\n\n return instance.object;\n }\n})();\n\nlet userContainer: { get<T>(someClass: { new (...args: any[]): T }|Function): T };\nlet userContainerOptions: UseContainerOptions;\n\n/**\n * Sets container to be used by this library.\n */\nexport function useContainer(iocContainer: { get(someClass: any): any }, options?: UseContainerOptions) {\n userContainer = iocContainer;\n userContainerOptions = options;\n}\n\n/**\n * Gets the IOC container used by this library.\n */\nexport function getFromContainer<T>(someClass: { new (...args: any[]): T }|Function): T {\n if (userContainer) {\n try {\n const instance = userContainer.get(someClass);\n if (instance)\n return instance;\n\n if (!userContainerOptions || !userContainerOptions.fallback)\n return instance;\n\n } catch (error) {\n if (!userContainerOptions || !userContainerOptions.fallbackOnErrors)\n throw error;\n }\n }\n return defaultContainer.get<T>(someClass);\n}\n"],"sourceRoot":"."}

View File

@@ -0,0 +1,12 @@
export function isValidationOptions(val) {
if (!val) {
return false;
}
return "each" in val
|| "message" in val
|| "groups" in val
|| "always" in val
|| "context" in val;
}
//# sourceMappingURL=ValidationOptions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/ValidationOptions.ts"],"names":[],"mappings":"AAmCA,MAAM,UAAU,mBAAmB,CAAC,GAAQ;IACxC,IAAI,CAAC,GAAG,EAAE;QACN,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,MAAM,IAAI,GAAG;WACb,SAAS,IAAI,GAAG;WAChB,QAAQ,IAAI,GAAG;WACf,QAAQ,IAAI,GAAG;WACf,SAAS,IAAI,GAAG,CAAC;AAC5B,CAAC","file":"ValidationOptions.js","sourcesContent":["import { ValidationArguments } from \"../validation/ValidationArguments\";\n\n/**\n * Options used to pass to validation decorators.\n */\nexport interface ValidationOptions {\n\n /**\n * Specifies if validated value is an array and each of its items must be validated.\n */\n each?: boolean;\n\n /**\n * Error message to be used on validation fail.\n * Message can be either string or a function that returns a string.\n */\n message?: string | ((validationArguments: ValidationArguments) => string);\n\n /**\n * Validation groups used for this validation.\n */\n groups?: string[];\n\n /**\n * Indicates if validation must be performed always, no matter of validation groups used.\n */\n always?: boolean;\n\n /*\n * A transient set of data passed through to the validation result for response mapping\n */\n context?: any;\n}\n\n\nexport function isValidationOptions(val: any): val is ValidationOptions {\n if (!val) {\n return false;\n }\n return \"each\" in val\n || \"message\" in val\n || \"groups\" in val\n || \"always\" in val\n || \"context\" in val;\n}\n"],"sourceRoot":".."}

View File

@@ -0,0 +1,27 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const ARRAY_CONTAINS = "arrayContains";
/**
* Checks if array contains all values from the given array of values.
* If null or undefined is given then this function returns false.
*/
export function arrayContains(array, values) {
if (!(array instanceof Array))
return false;
return values.every(value => array.indexOf(value) !== -1);
}
/**
* Checks if array contains all values from the given array of values.
* If null or undefined is given then this function returns false.
*/
export function ArrayContains(values, validationOptions) {
return ValidateBy({
name: ARRAY_CONTAINS,
constraints: [values],
validator: {
validate: (value, args) => arrayContains(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must contain $constraint1 values", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=ArrayContains.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/array/ArrayContains.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,MAAa;IACvD,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QACzB,OAAO,KAAK,CAAC;IAEjB,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAa,EAAE,iBAAqC;IAC9E,OAAO,UAAU,CACb;QACI,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACpE,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,4CAA4C,EACzE,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"ArrayContains.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const ARRAY_CONTAINS = \"arrayContains\";\n\n/**\n * Checks if array contains all values from the given array of values.\n * If null or undefined is given then this function returns false.\n */\nexport function arrayContains(array: unknown, values: any[]) {\n if (!(array instanceof Array))\n return false;\n\n return values.every(value => array.indexOf(value) !== -1);\n}\n\n/**\n * Checks if array contains all values from the given array of values.\n * If null or undefined is given then this function returns false.\n */\nexport function ArrayContains(values: any[], validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: ARRAY_CONTAINS,\n constraints: [values],\n validator: {\n validate: (value, args) => arrayContains(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must contain $constraint1 values\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const ARRAY_MAX_SIZE = "arrayMaxSize";
/**
* Checks if array's length is as maximal this number.
* If null or undefined is given then this function returns false.
*/
export function arrayMaxSize(array, max) {
return array instanceof Array && array.length <= max;
}
/**
* Checks if array's length is as maximal this number.
* If null or undefined is given then this function returns false.
*/
export function ArrayMaxSize(max, validationOptions) {
return ValidateBy({
name: ARRAY_MAX_SIZE,
constraints: [max],
validator: {
validate: (value, args) => arrayMaxSize(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must contain not more than $constraint1 elements", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=ArrayMaxSize.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/array/ArrayMaxSize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,GAAW;IACpD,OAAO,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,iBAAqC;IAC3E,OAAO,UAAU,CACb;QACI,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,CAAC,GAAG,CAAC;QAClB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACnE,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,4DAA4D,EACzF,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"ArrayMaxSize.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const ARRAY_MAX_SIZE = \"arrayMaxSize\";\n\n/**\n * Checks if array's length is as maximal this number.\n * If null or undefined is given then this function returns false.\n */\nexport function arrayMaxSize(array: unknown, max: number) {\n return array instanceof Array && array.length <= max;\n}\n\n/**\n * Checks if array's length is as maximal this number.\n * If null or undefined is given then this function returns false.\n */\nexport function ArrayMaxSize(max: number, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: ARRAY_MAX_SIZE,\n constraints: [max],\n validator: {\n validate: (value, args) => arrayMaxSize(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must contain not more than $constraint1 elements\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const ARRAY_MIN_SIZE = "arrayMinSize";
/**
* Checks if array's length is as minimal this number.
* If null or undefined is given then this function returns false.
*/
export function arrayMinSize(array, min) {
return array instanceof Array && array.length >= min;
}
/**
* Checks if array's length is as minimal this number.
* If null or undefined is given then this function returns false.
*/
export function ArrayMinSize(min, validationOptions) {
return ValidateBy({
name: ARRAY_MIN_SIZE,
constraints: [min],
validator: {
validate: (value, args) => arrayMinSize(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must contain at least $constraint1 elements", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=ArrayMinSize.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/array/ArrayMinSize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,GAAW;IACpD,OAAO,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,iBAAqC;IAC3E,OAAO,UAAU,CACb;QACI,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,CAAC,GAAG,CAAC;QAClB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACnE,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,uDAAuD,EACpF,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"ArrayMinSize.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const ARRAY_MIN_SIZE = \"arrayMinSize\";\n\n/**\n * Checks if array's length is as minimal this number.\n * If null or undefined is given then this function returns false.\n */\nexport function arrayMinSize(array: unknown, min: number) {\n return array instanceof Array && array.length >= min;\n}\n\n/**\n * Checks if array's length is as minimal this number.\n * If null or undefined is given then this function returns false.\n */\nexport function ArrayMinSize(min: number, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: ARRAY_MIN_SIZE,\n constraints: [min],\n validator: {\n validate: (value, args) => arrayMinSize(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must contain at least $constraint1 elements\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,27 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const ARRAY_NOT_CONTAINS = "arrayNotContains";
/**
* Checks if array does not contain any of the given values.
* If null or undefined is given then this function returns false.
*/
export function arrayNotContains(array, values) {
if (!(array instanceof Array))
return false;
return values.every(value => array.indexOf(value) === -1);
}
/**
* Checks if array does not contain any of the given values.
* If null or undefined is given then this function returns false.
*/
export function ArrayNotContains(values, validationOptions) {
return ValidateBy({
name: ARRAY_NOT_CONTAINS,
constraints: [values],
validator: {
validate: (value, args) => arrayNotContains(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property should not contain $constraint1 values", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=ArrayNotContains.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/array/ArrayNotContains.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAErD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc,EAAE,MAAa;IAC1D,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QACzB,OAAO,KAAK,CAAC;IAEjB,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAa,EAAE,iBAAqC;IACjF,OAAO,UAAU,CACb;QACI,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACvE,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,kDAAkD,EAC/E,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"ArrayNotContains.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const ARRAY_NOT_CONTAINS = \"arrayNotContains\";\n\n/**\n * Checks if array does not contain any of the given values.\n * If null or undefined is given then this function returns false.\n */\nexport function arrayNotContains(array: unknown, values: any[]) {\n if (!(array instanceof Array))\n return false;\n\n return values.every(value => array.indexOf(value) === -1);\n}\n\n/**\n * Checks if array does not contain any of the given values.\n * If null or undefined is given then this function returns false.\n */\nexport function ArrayNotContains(values: any[], validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: ARRAY_NOT_CONTAINS,\n constraints: [values],\n validator: {\n validate: (value, args) => arrayNotContains(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property should not contain $constraint1 values\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const ARRAY_NOT_EMPTY = "arrayNotEmpty";
/**
* Checks if given array is not empty.
* If null or undefined is given then this function returns false.
*/
export function arrayNotEmpty(array) {
return array instanceof Array && array.length > 0;
}
/**
* Checks if given array is not empty.
* If null or undefined is given then this function returns false.
*/
export function ArrayNotEmpty(validationOptions) {
return ValidateBy({
name: ARRAY_NOT_EMPTY,
validator: {
validate: (value, args) => arrayNotEmpty(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property should not be empty", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=ArrayNotEmpty.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/array/ArrayNotEmpty.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IACxC,OAAO,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,iBAAqC;IAC/D,OAAO,UAAU,CACb;QACI,IAAI,EAAE,eAAe;QACrB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC;YAC/C,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,+BAA+B,EAC5D,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"ArrayNotEmpty.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const ARRAY_NOT_EMPTY = \"arrayNotEmpty\";\n\n/**\n * Checks if given array is not empty.\n * If null or undefined is given then this function returns false.\n */\nexport function arrayNotEmpty(array: unknown) {\n return array instanceof Array && array.length > 0;\n}\n\n/**\n * Checks if given array is not empty.\n * If null or undefined is given then this function returns false.\n */\nexport function ArrayNotEmpty(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: ARRAY_NOT_EMPTY,\n validator: {\n validate: (value, args) => arrayNotEmpty(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property should not be empty\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,27 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const ARRAY_UNIQUE = "arrayUnique";
/**
* 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.
*/
export function arrayUnique(array) {
if (!(array instanceof Array))
return false;
const uniqueItems = array.filter((a, b, c) => c.indexOf(a) === b);
return array.length === uniqueItems.length;
}
/**
* 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.
*/
export function ArrayUnique(validationOptions) {
return ValidateBy({
name: ARRAY_UNIQUE,
validator: {
validate: (value, args) => arrayUnique(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "All $property's elements must be unique", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=ArrayUnique.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/array/ArrayUnique.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACtC,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QACzB,OAAO,KAAK,CAAC;IAEjB,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,iBAAqC;IAC7D,OAAO,UAAU,CACb;QACI,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC;YAC7C,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,yCAAyC,EACtE,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"ArrayUnique.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const ARRAY_UNIQUE = \"arrayUnique\";\n\n/**\n * Checks if all array's values are unique. Comparison for objects is reference-based.\n * If null or undefined is given then this function returns false.\n */\nexport function arrayUnique(array: unknown) {\n if (!(array instanceof Array))\n return false;\n\n const uniqueItems = array.filter((a, b, c) => c.indexOf(a) === b);\n return array.length === uniqueItems.length;\n}\n\n/**\n * Checks if all array's values are unique. Comparison for objects is reference-based.\n * If null or undefined is given then this function returns false.\n */\nexport function ArrayUnique(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: ARRAY_UNIQUE,\n validator: {\n validate: (value, args) => arrayUnique(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"All $property's elements must be unique\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,19 @@
import { ValidationTypes } from "../../validation/ValidationTypes";
import { ValidationMetadata } from "../../metadata/ValidationMetadata";
import { getMetadataStorage } from "../../metadata/MetadataStorage";
/**
* If object has both allowed and not allowed properties a validation error will be thrown.
*/
export function Allow(validationOptions) {
return function (object, propertyName) {
const args = {
type: ValidationTypes.WHITELIST,
target: object.constructor,
propertyName: propertyName,
validationOptions: validationOptions
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=Allow.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/Allow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,iBAAqC;IACvD,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,MAAM,IAAI,GAA2B;YACjC,IAAI,EAAE,eAAe,CAAC,SAAS;YAC/B,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,iBAAiB,EAAE,iBAAiB;SACvC,CAAC;QACF,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC;AACN,CAAC","file":"Allow.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { ValidationMetadataArgs } from \"../../metadata/ValidationMetadataArgs\";\nimport { ValidationTypes } from \"../../validation/ValidationTypes\";\nimport { ValidationMetadata } from \"../../metadata/ValidationMetadata\";\nimport { getMetadataStorage } from \"../../metadata/MetadataStorage\";\n\n/**\n * If object has both allowed and not allowed properties a validation error will be thrown.\n */\nexport function Allow(validationOptions?: ValidationOptions): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n const args: ValidationMetadataArgs = {\n type: ValidationTypes.WHITELIST,\n target: object.constructor,\n propertyName: propertyName,\n validationOptions: validationOptions\n };\n getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));\n };\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const EQUALS = "equals";
/**
* Checks if value matches ("===") the comparison.
*/
export function equals(value, comparison) {
return value === comparison;
}
/**
* Checks if value matches ("===") the comparison.
*/
export function Equals(comparison, validationOptions) {
return ValidateBy({
name: EQUALS,
constraints: [comparison],
validator: {
validate: (value, args) => equals(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be equal to $constraint1", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=Equals.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/Equals.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;AAE/B;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc,EAAE,UAAmB;IACtD,OAAO,KAAK,KAAK,UAAU,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,UAAe,EAAE,iBAAqC;IACzE,OAAO,UAAU,CACb;QACI,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,CAAC,UAAU,CAAC;QACzB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC7D,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,yCAAyC,EACtE,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"Equals.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const EQUALS = \"equals\";\n\n/**\n * Checks if value matches (\"===\") the comparison.\n */\nexport function equals(value: unknown, comparison: unknown): boolean {\n return value === comparison;\n}\n\n/**\n * Checks if value matches (\"===\") the comparison.\n */\nexport function Equals(comparison: any, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: EQUALS,\n constraints: [comparison],\n validator: {\n validate: (value, args) => equals(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be equal to $constraint1\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from "./ValidateBy";
import { ValidationTypes } from "../../validation/ValidationTypes";
// isDefined is (yet) a special case
export const IS_DEFINED = ValidationTypes.IS_DEFINED;
/**
* Checks if value is defined (!== undefined, !== null).
*/
export function isDefined(value) {
return value !== undefined && value !== null;
}
/**
* Checks if value is defined (!== undefined, !== null).
*/
export function IsDefined(validationOptions) {
return ValidateBy({
name: IS_DEFINED,
validator: {
validate: (value) => isDefined(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property should not be null or undefined", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsDefined.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/IsDefined.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,oCAAoC;AACpC,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC,UAAU,CAAC;AAErD;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAU;IAChC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,iBAAqC;IAC3D,OAAO,UAAU,CACb;QACI,IAAI,EAAE,UAAU;QAChB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;YACrC,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,2CAA2C,EACxE,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsDefined.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"./ValidateBy\";\nimport { ValidationTypes } from \"../../validation/ValidationTypes\";\n\n// isDefined is (yet) a special case\nexport const IS_DEFINED = ValidationTypes.IS_DEFINED;\n\n/**\n * Checks if value is defined (!== undefined, !== null).\n */\nexport function isDefined(value: any): boolean {\n return value !== undefined && value !== null;\n}\n\n/**\n * Checks if value is defined (!== undefined, !== null).\n */\nexport function IsDefined(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_DEFINED,\n validator: {\n validate: (value) => isDefined(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property should not be null or undefined\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const IS_EMPTY = "isEmpty";
/**
* Checks if given value is empty (=== '', === null, === undefined).
*/
export function isEmpty(value) {
return value === "" || value === null || value === undefined;
}
/**
* Checks if given value is empty (=== '', === null, === undefined).
*/
export function IsEmpty(validationOptions) {
return ValidateBy({
name: IS_EMPTY,
validator: {
validate: (value, args) => isEmpty(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be empty", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsEmpty.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/IsEmpty.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC;AAElC;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc;IAClC,OAAO,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,iBAAqC;IACzD,OAAO,UAAU,CACb;QACI,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;YACzC,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,yBAAyB,EACtD,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsEmpty.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const IS_EMPTY = \"isEmpty\";\n\n/**\n * Checks if given value is empty (=== '', === null, === undefined).\n */\nexport function isEmpty(value: unknown): boolean {\n return value === \"\" || value === null || value === undefined;\n}\n\n/**\n * Checks if given value is empty (=== '', === null, === undefined).\n */\nexport function IsEmpty(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_EMPTY,\n validator: {\n validate: (value, args) => isEmpty(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be empty\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const IS_IN = "isIn";
/**
* Checks if given value is in a array of allowed values.
*/
export function isIn(value, possibleValues) {
return !(possibleValues instanceof Array) || possibleValues.some(possibleValue => possibleValue === value);
}
/**
* Checks if given value is in a array of allowed values.
*/
export function IsIn(values, validationOptions) {
return ValidateBy({
name: IS_IN,
constraints: [values],
validator: {
validate: (value, args) => isIn(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be one of the following values: $constraint1", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsIn.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/IsIn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC;AAE5B;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,KAAc,EAAE,cAAyB;IAC1D,OAAO,CAAC,CAAC,cAAc,YAAY,KAAK,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,aAAa,KAAK,KAAK,CAAC,CAAC;AAC/G,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,MAAa,EAAE,iBAAqC;IACrE,OAAO,UAAU,CACb;QACI,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC3D,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,6DAA6D,EAC1F,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsIn.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const IS_IN = \"isIn\";\n\n/**\n * Checks if given value is in a array of allowed values.\n */\nexport function isIn(value: unknown, possibleValues: unknown[]): boolean {\n return !(possibleValues instanceof Array) || possibleValues.some(possibleValue => possibleValue === value);\n}\n\n/**\n * Checks if given value is in a array of allowed values.\n */\nexport function IsIn(values: any[], validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_IN,\n constraints: [values],\n validator: {\n validate: (value, args) => isIn(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be one of the following values: $constraint1\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from "./ValidateBy";
import validator from "validator";
export const IS_LATLONG = "isLatLong";
/**
* Checks if a value is string in format a "latitude,longitude".
*/
export function isLatLong(value) {
return typeof value === "string" && validator.isLatLong(value);
}
/**
* Checks if a value is string in format a "latitude,longitude".
*/
export function IsLatLong(validationOptions) {
return ValidateBy({
name: IS_LATLONG,
validator: {
validate: (value, args) => isLatLong(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be a latitude,longitude string", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsLatLong.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/IsLatLong.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC;AAEtC;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,iBAAqC;IAC3D,OAAO,UAAU,CACb;QACI,IAAI,EAAE,UAAU;QAChB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;YAC3C,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,+CAA+C,EAC5E,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsLatLong.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"./ValidateBy\";\nimport validator from \"validator\";\n\nexport const IS_LATLONG = \"isLatLong\";\n\n/**\n * Checks if a value is string in format a \"latitude,longitude\".\n */\nexport function isLatLong(value: string): boolean {\n return typeof value === \"string\" && validator.isLatLong(value);\n}\n\n/**\n * Checks if a value is string in format a \"latitude,longitude\".\n */\nexport function IsLatLong(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_LATLONG,\n validator: {\n validate: (value, args) => isLatLong(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be a latitude,longitude string\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from "./ValidateBy";
import { isLatLong } from "./IsLatLong";
export const IS_LATITUDE = "isLatitude";
/**
* Checks if a given value is a latitude.
*/
export function isLatitude(value) {
return (typeof value === "number" || typeof value === "string") && isLatLong(`${value},0`);
}
/**
* Checks if a given value is a latitude.
*/
export function IsLatitude(validationOptions) {
return ValidateBy({
name: IS_LATITUDE,
validator: {
validate: (value, args) => isLatitude(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be a latitude string or number", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsLatitude.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/IsLatitude.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACpC,OAAO,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,IAAI,SAAS,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;AAC/F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,iBAAqC;IAC5D,OAAO,UAAU,CACb;QACI,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;YAC5C,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,+CAA+C,EAC5E,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsLatitude.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"./ValidateBy\";\nimport { isLatLong } from \"./IsLatLong\";\n\nexport const IS_LATITUDE = \"isLatitude\";\n\n/**\n * Checks if a given value is a latitude.\n */\nexport function isLatitude(value: string): boolean {\n return (typeof value === \"number\" || typeof value === \"string\") && isLatLong(`${value},0`);\n}\n\n/**\n * Checks if a given value is a latitude.\n */\nexport function IsLatitude(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_LATITUDE,\n validator: {\n validate: (value, args) => isLatitude(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be a latitude string or number\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from "./ValidateBy";
import { isLatLong } from "./IsLatLong";
export const IS_LONGITUDE = "isLongitude";
/**
* Checks if a given value is a longitude.
*/
export function isLongitude(value) {
return (typeof value === "number" || typeof value === "string") && isLatLong(`0,${value}`);
}
/**
* Checks if a given value is a longitude.
*/
export function IsLongitude(validationOptions) {
return ValidateBy({
name: IS_LONGITUDE,
validator: {
validate: (value, args) => isLongitude(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be a longitude string or number", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsLongitude.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/IsLongitude.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;AAE1C;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACrC,OAAO,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,IAAI,SAAS,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC;AAC/F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,iBAAqC;IAC7D,OAAO,UAAU,CACb;QACI,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC;YAC7C,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,gDAAgD,EAC7E,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsLongitude.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"./ValidateBy\";\nimport { isLatLong } from \"./IsLatLong\";\n\nexport const IS_LONGITUDE = \"isLongitude\";\n\n/**\n * Checks if a given value is a longitude.\n */\nexport function isLongitude(value: string): boolean {\n return (typeof value === \"number\" || typeof value === \"string\") && isLatLong(`0,${value}`);\n}\n\n/**\n * Checks if a given value is a longitude.\n */\nexport function IsLongitude(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_LONGITUDE,\n validator: {\n validate: (value, args) => isLongitude(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be a longitude string or number\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const IS_NOT_EMPTY = "isNotEmpty";
/**
* Checks if given value is not empty (!== '', !== null, !== undefined).
*/
export function isNotEmpty(value) {
return value !== "" && value !== null && value !== undefined;
}
/**
* Checks if given value is not empty (!== '', !== null, !== undefined).
*/
export function IsNotEmpty(validationOptions) {
return ValidateBy({
name: IS_NOT_EMPTY,
validator: {
validate: (value, args) => isNotEmpty(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property should not be empty", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsNotEmpty.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/IsNotEmpty.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACrC,OAAO,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,iBAAqC;IAC5D,OAAO,UAAU,CACb;QACI,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;YAC5C,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,+BAA+B,EAC5D,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsNotEmpty.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const IS_NOT_EMPTY = \"isNotEmpty\";\n\n/**\n * Checks if given value is not empty (!== '', !== null, !== undefined).\n */\nexport function isNotEmpty(value: unknown): boolean {\n return value !== \"\" && value !== null && value !== undefined;\n}\n\n/**\n * Checks if given value is not empty (!== '', !== null, !== undefined).\n */\nexport function IsNotEmpty(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_NOT_EMPTY,\n validator: {\n validate: (value, args) => isNotEmpty(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property should not be empty\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const IS_NOT_IN = "isNotIn";
/**
* Checks if given value not in a array of allowed values.
*/
export function isNotIn(value, possibleValues) {
return !(possibleValues instanceof Array) || !possibleValues.some(possibleValue => possibleValue === value);
}
/**
* Checks if given value not in a array of allowed values.
*/
export function IsNotIn(values, validationOptions) {
return ValidateBy({
name: IS_NOT_IN,
constraints: [values],
validator: {
validate: (value, args) => isNotIn(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property should not be one of the following values: $constraint1", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsNotIn.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/IsNotIn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC;AAEnC;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,cAAyB;IAC7D,OAAO,CAAC,CAAC,cAAc,YAAY,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,aAAa,KAAK,KAAK,CAAC,CAAC;AAChH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,MAAa,EAAE,iBAAqC;IACxE,OAAO,UAAU,CACb;QACI,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC9D,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,mEAAmE,EAChG,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsNotIn.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const IS_NOT_IN = \"isNotIn\";\n\n/**\n * Checks if given value not in a array of allowed values.\n */\nexport function isNotIn(value: unknown, possibleValues: unknown[]): boolean {\n return !(possibleValues instanceof Array) || !possibleValues.some(possibleValue => possibleValue === value);\n}\n\n/**\n * Checks if given value not in a array of allowed values.\n */\nexport function IsNotIn(values: any[], validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_NOT_IN,\n constraints: [values],\n validator: {\n validate: (value, args) => isNotIn(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property should not be one of the following values: $constraint1\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,22 @@
import { ValidationTypes } from "../../validation/ValidationTypes";
import { ValidationMetadata } from "../../metadata/ValidationMetadata";
import { getMetadataStorage } from "../../metadata/MetadataStorage";
/**
* Checks if value is missing and if so, ignores all validators.
*/
export function IsOptional(validationOptions) {
return function (object, propertyName) {
const args = {
type: ValidationTypes.CONDITIONAL_VALIDATION,
target: object.constructor,
propertyName: propertyName,
constraints: [(object, value) => {
return object[propertyName] !== null && object[propertyName] !== undefined;
}],
validationOptions: validationOptions
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=IsOptional.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/IsOptional.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,iBAAqC;IAC5D,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,MAAM,IAAI,GAA2B;YACjC,IAAI,EAAE,eAAe,CAAC,sBAAsB;YAC5C,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,CAAC,CAAC,MAAW,EAAE,KAAU,EAAE,EAAE;oBACtC,OAAO,MAAM,CAAC,YAAY,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,SAAS,CAAC;gBAC/E,CAAC,CAAC;YACF,iBAAiB,EAAE,iBAAiB;SACvC,CAAC;QACF,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC;AACN,CAAC","file":"IsOptional.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { ValidationMetadataArgs } from \"../../metadata/ValidationMetadataArgs\";\nimport { ValidationTypes } from \"../../validation/ValidationTypes\";\nimport { ValidationMetadata } from \"../../metadata/ValidationMetadata\";\nimport { getMetadataStorage } from \"../../metadata/MetadataStorage\";\n\n/**\n * Checks if value is missing and if so, ignores all validators.\n */\nexport function IsOptional(validationOptions?: ValidationOptions): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n const args: ValidationMetadataArgs = {\n type: ValidationTypes.CONDITIONAL_VALIDATION,\n target: object.constructor,\n propertyName: propertyName,\n constraints: [(object: any, value: any) => {\n return object[propertyName] !== null && object[propertyName] !== undefined;\n }],\n validationOptions: validationOptions\n };\n getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));\n };\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const NOT_EQUALS = "notEquals";
/**
* Checks if value does not match ("!==") the comparison.
*/
export function notEquals(value, comparison) {
return value !== comparison;
}
/**
* Checks if value does not match ("!==") the comparison.
*/
export function NotEquals(comparison, validationOptions) {
return ValidateBy({
name: NOT_EQUALS,
constraints: [comparison],
validator: {
validate: (value, args) => notEquals(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property should not be equal to $constraint1", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=NotEquals.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/NotEquals.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC;AAEtC;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,UAAmB;IACzD,OAAO,KAAK,KAAK,UAAU,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,UAAe,EAAE,iBAAqC;IAC5E,OAAO,UAAU,CACb;QACI,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,CAAC,UAAU,CAAC;QACzB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAChE,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,+CAA+C,EAC5E,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"NotEquals.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const NOT_EQUALS = \"notEquals\";\n\n/**\n * Checks if value does not match (\"!==\") the comparison.\n */\nexport function notEquals(value: unknown, comparison: unknown): boolean {\n return value !== comparison;\n}\n\n/**\n * Checks if value does not match (\"!==\") the comparison.\n */\nexport function NotEquals(comparison: any, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: NOT_EQUALS,\n constraints: [comparison],\n validator: {\n validate: (value, args) => notEquals(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property should not be equal to $constraint1\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,35 @@
import { ValidationMetadata } from "../../metadata/ValidationMetadata";
import { getMetadataStorage } from "../../metadata/MetadataStorage";
import { ValidationTypes } from "../../validation/ValidationTypes";
import { ConstraintMetadata } from "../../metadata/ConstraintMetadata";
/**
* Registers custom validator class.
*/
export function ValidatorConstraint(options) {
return function (target) {
const isAsync = options && options.async ? true : false;
let name = options && options.name ? options.name : "";
if (!name) {
name = target.name;
if (!name) // generate name if it was not given
name = name.replace(/\.?([A-Z]+)/g, (x, y) => "_" + y.toLowerCase()).replace(/^_/, "");
}
const metadata = new ConstraintMetadata(target, name, isAsync);
getMetadataStorage().addConstraintMetadata(metadata);
};
}
export function Validate(constraintClass, constraintsOrValidationOptions, maybeValidationOptions) {
return function (object, propertyName) {
const args = {
type: ValidationTypes.CUSTOM_VALIDATION,
target: object.constructor,
propertyName: propertyName,
constraintCls: constraintClass,
constraints: constraintsOrValidationOptions instanceof Array ? constraintsOrValidationOptions : undefined,
validationOptions: !(constraintsOrValidationOptions instanceof Array) ? constraintsOrValidationOptions : maybeValidationOptions
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=Validate.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/Validate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA4C;IAC5E,OAAO,UAAU,MAAgB;QAC7B,MAAM,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QACxD,IAAI,IAAI,GAAG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,IAAI,CAAC,IAAI,EAAE;YACP,IAAI,GAAI,MAAc,CAAC,IAAI,CAAC;YAC5B,IAAI,CAAC,IAAI,EAAE,oCAAoC;gBAC3C,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;SAC9F;QACD,MAAM,QAAQ,GAAG,IAAI,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/D,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC,CAAC;AACN,CAAC;AAQD,MAAM,UAAU,QAAQ,CAAC,eAAyB,EAAE,8BAA0D,EAAE,sBAA0C;IACtJ,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,MAAM,IAAI,GAA2B;YACjC,IAAI,EAAE,eAAe,CAAC,iBAAiB;YACvC,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,aAAa,EAAE,eAAe;YAC9B,WAAW,EAAE,8BAA8B,YAAY,KAAK,CAAC,CAAC,CAAC,8BAAuC,CAAC,CAAC,CAAC,SAAS;YAClH,iBAAiB,EAAE,CAAC,CAAC,8BAA8B,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,8BAAmD,CAAC,CAAC,CAAC,sBAAsB;SACvJ,CAAC;QACF,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC;AACN,CAAC","file":"Validate.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { ValidationMetadataArgs } from \"../../metadata/ValidationMetadataArgs\";\nimport { ValidationMetadata } from \"../../metadata/ValidationMetadata\";\nimport { getMetadataStorage } from \"../../metadata/MetadataStorage\";\nimport { ValidationTypes } from \"../../validation/ValidationTypes\";\nimport { ConstraintMetadata } from \"../../metadata/ConstraintMetadata\";\n\n/**\n * Registers custom validator class.\n */\nexport function ValidatorConstraint(options?: { name?: string, async?: boolean }) {\n return function (target: Function) {\n const isAsync = options && options.async ? true : false;\n let name = options && options.name ? options.name : \"\";\n if (!name) {\n name = (target as any).name;\n if (!name) // generate name if it was not given\n name = name.replace(/\\.?([A-Z]+)/g, (x, y) => \"_\" + y.toLowerCase()).replace(/^_/, \"\");\n }\n const metadata = new ConstraintMetadata(target, name, isAsync);\n getMetadataStorage().addConstraintMetadata(metadata);\n };\n}\n\n/**\n * Performs validation based on the given custom validation class.\n * Validation class must be decorated with ValidatorConstraint decorator.\n */\nexport function Validate(constraintClass: Function, validationOptions?: ValidationOptions): PropertyDecorator;\nexport function Validate(constraintClass: Function, constraints?: any[], validationOptions?: ValidationOptions): PropertyDecorator;\nexport function Validate(constraintClass: Function, constraintsOrValidationOptions?: any[] | ValidationOptions, maybeValidationOptions?: ValidationOptions): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n const args: ValidationMetadataArgs = {\n type: ValidationTypes.CUSTOM_VALIDATION,\n target: object.constructor,\n propertyName: propertyName,\n constraintCls: constraintClass,\n constraints: constraintsOrValidationOptions instanceof Array ? constraintsOrValidationOptions as any[] : undefined,\n validationOptions: !(constraintsOrValidationOptions instanceof Array) ? constraintsOrValidationOptions as ValidationOptions : maybeValidationOptions\n };\n getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));\n };\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,23 @@
import { registerDecorator } from "../../register-decorator";
export function buildMessage(impl, validationOptions) {
return (validationArguments) => {
const eachPrefix = validationOptions && validationOptions.each
? "each value in "
: "";
return impl(eachPrefix, validationArguments);
};
}
export function ValidateBy(options, validationOptions) {
return function (object, propertyName) {
registerDecorator({
name: options.name,
target: object.constructor,
propertyName: propertyName,
options: validationOptions,
constraints: options.constraints,
validator: options.validator
});
};
}
//# sourceMappingURL=ValidateBy.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/ValidateBy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAW7D,MAAM,UAAU,YAAY,CACxB,IAAgE,EAChE,iBAAqC;IAErC,OAAO,CAAC,mBAAyC,EAAE,EAAE;QACjD,MAAM,UAAU,GAAG,iBAAiB,IAAI,iBAAiB,CAAC,IAAI;YAC1D,CAAC,CAAC,gBAAgB;YAClB,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,IAAI,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;IACjD,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,OAA0B,EAAE,iBAAqC;IACxF,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,iBAAiB,CAAC;YACd,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,OAAO,EAAE,iBAAiB;YAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,SAAS,EAAE,OAAO,CAAC,SAAS;SAC/B,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC","file":"ValidateBy.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { registerDecorator } from \"../../register-decorator\";\nimport { ValidationArguments } from \"../../validation/ValidationArguments\";\nimport { ValidatorConstraintInterface } from \"../../validation/ValidatorConstraintInterface\";\n\nexport interface ValidateByOptions {\n name: string;\n constraints?: any[];\n validator: ValidatorConstraintInterface | Function;\n async?: boolean;\n}\n\nexport function buildMessage(\n impl: (eachPrefix: string, args?: ValidationArguments) => string,\n validationOptions?: ValidationOptions)\n : (validationArguments?: ValidationArguments) => string {\n return (validationArguments?: ValidationArguments) => {\n const eachPrefix = validationOptions && validationOptions.each\n ? \"each value in \"\n : \"\";\n return impl(eachPrefix, validationArguments);\n };\n}\n\nexport function ValidateBy(options: ValidateByOptions, validationOptions?: ValidationOptions): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n registerDecorator({\n name: options.name,\n target: object.constructor,\n propertyName: propertyName,\n options: validationOptions,\n constraints: options.constraints,\n validator: options.validator\n });\n };\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,20 @@
import { ValidationTypes } from "../../validation/ValidationTypes";
import { ValidationMetadata } from "../../metadata/ValidationMetadata";
import { getMetadataStorage } from "../../metadata/MetadataStorage";
/**
* Objects / object arrays marked with this decorator will also be validated.
*/
export function ValidateIf(condition, validationOptions) {
return function (object, propertyName) {
const args = {
type: ValidationTypes.CONDITIONAL_VALIDATION,
target: object.constructor,
propertyName: propertyName,
constraints: [condition],
validationOptions: validationOptions
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=ValidateIf.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/ValidateIf.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,SAA+C,EAAE,iBAAqC;IAC7G,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,MAAM,IAAI,GAA2B;YACjC,IAAI,EAAE,eAAe,CAAC,sBAAsB;YAC5C,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE,CAAC,SAAS,CAAC;YACxB,iBAAiB,EAAE,iBAAiB;SACvC,CAAC;QACF,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC;AACN,CAAC","file":"ValidateIf.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { ValidationMetadataArgs } from \"../../metadata/ValidationMetadataArgs\";\nimport { ValidationTypes } from \"../../validation/ValidationTypes\";\nimport { ValidationMetadata } from \"../../metadata/ValidationMetadata\";\nimport { getMetadataStorage } from \"../../metadata/MetadataStorage\";\n\n/**\n * Objects / object arrays marked with this decorator will also be validated.\n */\nexport function ValidateIf(condition: (object: any, value: any) => boolean, validationOptions?: ValidationOptions): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n const args: ValidationMetadataArgs = {\n type: ValidationTypes.CONDITIONAL_VALIDATION,\n target: object.constructor,\n propertyName: propertyName,\n constraints: [condition],\n validationOptions: validationOptions\n };\n getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));\n };\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,22 @@
import { ValidationTypes } from "../../validation/ValidationTypes";
import { ValidationMetadata } from "../../metadata/ValidationMetadata";
import { getMetadataStorage } from "../../metadata/MetadataStorage";
/**
* Objects / object arrays marked with this decorator will also be validated.
*/
export function ValidateNested(validationOptions) {
const opts = { ...validationOptions };
const eachPrefix = opts.each ? "each value in " : "";
opts.message = opts.message || eachPrefix + "nested property $property must be either object or array";
return function (object, propertyName) {
const args = {
type: ValidationTypes.NESTED_VALIDATION,
target: object.constructor,
propertyName: propertyName,
validationOptions: opts,
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=ValidateNested.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/ValidateNested.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,iBAAqC;IAChE,MAAM,IAAI,GAAsB,EAAE,GAAG,iBAAiB,EAAE,CAAC;IACzD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,UAAU,GAAG,0DAA0D,CAAC;IAEvG,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,MAAM,IAAI,GAA2B;YACjC,IAAI,EAAE,eAAe,CAAC,iBAAiB;YACvC,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,iBAAiB,EAAE,IAAI;SAC1B,CAAC;QACF,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC;AACN,CAAC","file":"ValidateNested.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { ValidationMetadataArgs } from \"../../metadata/ValidationMetadataArgs\";\nimport { ValidationTypes } from \"../../validation/ValidationTypes\";\nimport { ValidationMetadata } from \"../../metadata/ValidationMetadata\";\nimport { getMetadataStorage } from \"../../metadata/MetadataStorage\";\n\n/**\n * Objects / object arrays marked with this decorator will also be validated.\n */\nexport function ValidateNested(validationOptions?: ValidationOptions): PropertyDecorator {\n const opts: ValidationOptions = { ...validationOptions };\n const eachPrefix = opts.each ? \"each value in \" : \"\";\n opts.message = opts.message || eachPrefix + \"nested property $property must be either object or array\";\n\n return function (object: Object, propertyName: string) {\n const args: ValidationMetadataArgs = {\n type: ValidationTypes.NESTED_VALIDATION,\n target: object.constructor,\n propertyName: propertyName,\n validationOptions: opts,\n };\n getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));\n };\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,19 @@
import { ValidationTypes } from "../../validation/ValidationTypes";
import { ValidationMetadata } from "../../metadata/ValidationMetadata";
import { getMetadataStorage } from "../../metadata/MetadataStorage";
/**
* Resolve promise before validation
*/
export function ValidatePromise(validationOptions) {
return function (object, propertyName) {
const args = {
type: ValidationTypes.PROMISE_VALIDATION,
target: object.constructor,
propertyName: propertyName,
validationOptions: validationOptions,
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=ValidatePromise.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/common/ValidatePromise.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,iBAAqC;IACjE,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,MAAM,IAAI,GAA2B;YACjC,IAAI,EAAE,eAAe,CAAC,kBAAkB;YACxC,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,iBAAiB,EAAE,iBAAiB;SACvC,CAAC;QACF,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC;AACN,CAAC","file":"ValidatePromise.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { ValidationMetadataArgs } from \"../../metadata/ValidationMetadataArgs\";\nimport { ValidationTypes } from \"../../validation/ValidationTypes\";\nimport { ValidationMetadata } from \"../../metadata/ValidationMetadata\";\nimport { getMetadataStorage } from \"../../metadata/MetadataStorage\";\n\n/**\n * Resolve promise before validation\n */\nexport function ValidatePromise(validationOptions?: ValidationOptions): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n const args: ValidationMetadataArgs = {\n type: ValidationTypes.PROMISE_VALIDATION,\n target: object.constructor,\n propertyName: propertyName,\n validationOptions: validationOptions,\n };\n getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));\n };\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const MAX_DATE = "maxDate";
/**
* Checks if the value is a date that's before the specified date.
*/
export function maxDate(date, maxDate) {
return date instanceof Date && date.getTime() <= maxDate.getTime();
}
/**
* Checks if the value is a date that's after the specified date.
*/
export function MaxDate(date, validationOptions) {
return ValidateBy({
name: MAX_DATE,
constraints: [date],
validator: {
validate: (value, args) => maxDate(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => "maximal allowed date for " + eachPrefix + "$property is $constraint1", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=MaxDate.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/date/MaxDate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC;AAEjC;;EAEE;AACH,MAAM,UAAU,OAAO,CAAC,IAAa,EAAE,OAAa;IAChD,OAAO,IAAI,YAAY,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;AACvE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,IAAU,EAAE,iBAAqC;IACrE,OAAO,UAAU,CACb;QACI,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,CAAC,IAAI,CAAC;QACnB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC9D,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,2BAA2B,GAAG,UAAU,GAAG,2BAA2B,EACtF,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"MaxDate.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const MAX_DATE = \"maxDate\";\n\n /**\n * Checks if the value is a date that's before the specified date.\n */\nexport function maxDate(date: unknown, maxDate: Date): boolean {\n return date instanceof Date && date.getTime() <= maxDate.getTime();\n}\n\n/**\n * Checks if the value is a date that's after the specified date.\n */\nexport function MaxDate(date: Date, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: MAX_DATE,\n constraints: [date],\n validator: {\n validate: (value, args) => maxDate(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => \"maximal allowed date for \" + eachPrefix + \"$property is $constraint1\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const MIN_DATE = "minDate";
/**
* Checks if the value is a date that's after the specified date.
*/
export function minDate(date, minDate) {
return date instanceof Date && date.getTime() >= minDate.getTime();
}
/**
* Checks if the value is a date that's after the specified date.
*/
export function MinDate(date, validationOptions) {
return ValidateBy({
name: MIN_DATE,
constraints: [date],
validator: {
validate: (value, args) => minDate(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => "minimal allowed date for " + eachPrefix + "$property is $constraint1", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=MinDate.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/date/MinDate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC;AAElC;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,IAAa,EAAE,OAAa;IAChD,OAAO,IAAI,YAAY,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;AACvE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,IAAU,EAAE,iBAAqC;IACrE,OAAO,UAAU,CACb;QACI,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,CAAC,IAAI,CAAC;QACnB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC9D,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,2BAA2B,GAAG,UAAU,GAAG,2BAA2B,EACtF,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"MinDate.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const MIN_DATE = \"minDate\";\n\n/**\n * Checks if the value is a date that's after the specified date.\n */\nexport function minDate(date: unknown, minDate: Date): boolean {\n return date instanceof Date && date.getTime() >= minDate.getTime();\n}\n\n/**\n * Checks if the value is a date that's after the specified date.\n */\nexport function MinDate(date: Date, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: MIN_DATE,\n constraints: [date],\n validator: {\n validate: (value, args) => minDate(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => \"minimal allowed date for \" + eachPrefix + \"$property is $constraint1\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,132 @@
// -------------------------------------------------------------------------
// System
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Common checkers
// -------------------------------------------------------------------------
export * from "./common/Allow";
export * from "./common/IsDefined";
export * from "./common/IsOptional";
export * from "./common/Validate";
export * from "./common/ValidateBy";
export * from "./common/ValidateIf";
export * from "./common/ValidateNested";
export * from "./common/ValidatePromise";
export * from "./common/IsLatLong";
export * from "./common/IsLatitude";
export * from "./common/IsLongitude";
export * from "./common/Equals";
export * from "./common/NotEquals";
export * from "./common/IsEmpty";
export * from "./common/IsNotEmpty";
export * from "./common/IsIn";
export * from "./common/IsNotIn";
// -------------------------------------------------------------------------
// Number checkers
// -------------------------------------------------------------------------
export * from "./number/IsDivisibleBy";
export * from "./number/IsPositive";
export * from "./number/IsNegative";
export * from "./number/Max";
export * from "./number/Min";
// -------------------------------------------------------------------------
// Date checkers
// -------------------------------------------------------------------------
export * from "./date/MinDate";
export * from "./date/MaxDate";
// -------------------------------------------------------------------------
// String checkers
// -------------------------------------------------------------------------
export * from "./string/Contains";
export * from "./string/NotContains";
export * from "./string/IsAlpha";
export * from "./string/IsAlphanumeric";
export * from "./string/IsDecimal";
export * from "./string/IsAscii";
export * from "./string/IsBase64";
export * from "./string/IsByteLength";
export * from "./string/IsCreditCard";
export * from "./string/IsCurrency";
export * from "./string/IsEmail";
export * from "./string/IsFQDN";
export * from "./string/IsFullWidth";
export * from "./string/IsHalfWidth";
export * from "./string/IsVariableWidth";
export * from "./string/IsHexColor";
export * from "./string/IsHexadecimal";
export * from "./string/IsMacAddress";
export * from "./string/IsIP";
export * from "./string/IsPort";
export * from "./string/IsISBN";
export * from "./string/IsISIN";
export * from "./string/IsISO8601";
export * from "./string/IsJSON";
export * from "./string/IsJWT";
export * from "./string/IsLowercase";
export * from "./string/IsMobilePhone";
export * from "./string/IsISO31661Alpha2";
export * from "./string/IsISO31661Alpha3";
export * from "./string/IsMongoId";
export * from "./string/IsMultibyte";
export * from "./string/IsSurrogatePair";
export * from "./string/IsUrl";
export * from "./string/IsUUID";
export * from "./string/IsFirebasePushId";
export * from "./string/IsUppercase";
export * from "./string/Length";
export * from "./string/MaxLength";
export * from "./string/MinLength";
export * from "./string/Matches";
export * from "./string/IsPhoneNumber";
export * from "./string/IsMilitaryTime";
export * from "./string/IsHash";
export * from "./string/IsISSN";
export * from "./string/IsDateString";
export * from "./string/IsBooleanString";
export * from "./string/IsNumberString";
export * from "./string/IsBase32";
export * from "./string/IsBIC";
export * from "./string/IsBtcAddress";
export * from "./string/IsDataURI";
export * from "./string/IsEAN";
export * from "./string/IsEthereumAddress";
export * from "./string/IsHSL";
export * from "./string/IsIBAN";
export * from "./string/IsIdentityCard";
export * from "./string/IsISRC";
export * from "./string/IsLocale";
export * from "./string/IsMagnetURI";
export * from "./string/IsMimeType";
export * from "./string/IsOctal";
export * from "./string/IsPassportNumber";
export * from "./string/IsPostalCode";
export * from "./string/IsRFC3339";
export * from "./string/IsRgbColor";
export * from "./string/IsSemVer";
// -------------------------------------------------------------------------
// Type checkers
// -------------------------------------------------------------------------
export * from "./typechecker/IsBoolean";
export * from "./typechecker/IsDate";
export * from "./typechecker/IsNumber";
export * from "./typechecker/IsEnum";
export * from "./typechecker/IsInt";
export * from "./typechecker/IsString";
export * from "./typechecker/IsArray";
export * from "./typechecker/IsObject";
// -------------------------------------------------------------------------
// Array checkers
// -------------------------------------------------------------------------
export * from "./array/ArrayContains";
export * from "./array/ArrayNotContains";
export * from "./array/ArrayNotEmpty";
export * from "./array/ArrayMinSize";
export * from "./array/ArrayMaxSize";
export * from "./array/ArrayUnique";
// -------------------------------------------------------------------------
// Object checkers
// -------------------------------------------------------------------------
export * from "./object/IsNotEmptyObject";
export * from "./object/IsInstance";
//# sourceMappingURL=decorators.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,26 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
import validator from "validator";
export const IS_DIVISIBLE_BY = "isDivisibleBy";
/**
* Checks if value is a number that's divisible by another.
*/
export function isDivisibleBy(value, num) {
return typeof value === "number" &&
typeof num === "number" &&
validator.isDivisibleBy(String(value), num);
}
/**
* Checks if value is a number that's divisible by another.
*/
export function IsDivisibleBy(num, validationOptions) {
return ValidateBy({
name: IS_DIVISIBLE_BY,
constraints: [num],
validator: {
validate: (value, args) => isDivisibleBy(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be divisible by $constraint1", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsDivisibleBy.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/number/IsDivisibleBy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;AAE/C;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,GAAW;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ;QAC5B,OAAO,GAAG,KAAK,QAAQ;QACvB,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,iBAAqC;IAC5E,OAAO,UAAU,CACb;QACI,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,CAAC,GAAG,CAAC;QAClB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACpE,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,6CAA6C,EAC1E,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsDivisibleBy.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\nimport validator from \"validator\";\n\nexport const IS_DIVISIBLE_BY = \"isDivisibleBy\";\n\n/**\n * Checks if value is a number that's divisible by another.\n */\nexport function isDivisibleBy(value: unknown, num: number): boolean {\n return typeof value === \"number\" &&\n typeof num === \"number\" &&\n validator.isDivisibleBy(String(value), num);\n}\n\n/**\n * Checks if value is a number that's divisible by another.\n */\nexport function IsDivisibleBy(num: number, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_DIVISIBLE_BY,\n constraints: [num],\n validator: {\n validate: (value, args) => isDivisibleBy(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be divisible by $constraint1\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const IS_NEGATIVE = "isNegative";
/**
* Checks if the value is a negative number smaller than zero.
*/
export function isNegative(value) {
return typeof value === "number" && value < 0;
}
/**
* Checks if the value is a negative number smaller than zero.
*/
export function IsNegative(validationOptions) {
return ValidateBy({
name: IS_NEGATIVE,
validator: {
validate: (value, args) => isNegative(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be a negative number", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsNegative.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/number/IsNegative.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,iBAAqC;IAC5D,OAAO,UAAU,CACb;QACI,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;YAC5C,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,qCAAqC,EAClE,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsNegative.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const IS_NEGATIVE = \"isNegative\";\n\n/**\n * Checks if the value is a negative number smaller than zero.\n */\nexport function isNegative(value: unknown): boolean {\n return typeof value === \"number\" && value < 0;\n}\n\n/**\n * Checks if the value is a negative number smaller than zero.\n */\nexport function IsNegative(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_NEGATIVE,\n validator: {\n validate: (value, args) => isNegative(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be a negative number\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const IS_POSITIVE = "isPositive";
/**
* Checks if the value is a positive number greater than zero.
*/
export function isPositive(value) {
return typeof value === "number" && value > 0;
}
/**
* Checks if the value is a positive number greater than zero.
*/
export function IsPositive(validationOptions) {
return ValidateBy({
name: IS_POSITIVE,
validator: {
validate: (value, args) => isPositive(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be a positive number", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsPositive.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/number/IsPositive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,iBAAqC;IAC5D,OAAO,UAAU,CACb;QACI,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;YAC5C,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,qCAAqC,EAClE,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsPositive.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const IS_POSITIVE = \"isPositive\";\n\n/**\n * Checks if the value is a positive number greater than zero.\n */\nexport function isPositive(value: unknown): boolean {\n return typeof value === \"number\" && value > 0;\n}\n\n/**\n * Checks if the value is a positive number greater than zero.\n */\nexport function IsPositive(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_POSITIVE,\n validator: {\n validate: (value, args) => isPositive(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be a positive number\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const MAX = "max";
/**
* Checks if the first number is less than or equal to the second.
*/
export function max(num, max) {
return typeof num === "number" && typeof max === "number" && num <= max;
}
/**
* Checks if the first number is less than or equal to the second.
*/
export function Max(maxValue, validationOptions) {
return ValidateBy({
name: MAX,
constraints: [maxValue],
validator: {
validate: (value, args) => max(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must not be greater than $constraint1", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=Max.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/number/Max.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;AAEzB;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,GAAY,EAAE,GAAW;IACzC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,IAAI,GAAG,CAAC;AAC5E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAE,iBAAqC;IACvE,OAAO,UAAU,CACb;QACI,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC1D,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,iDAAiD,EAC9E,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"Max.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const MAX = \"max\";\n\n/**\n * Checks if the first number is less than or equal to the second.\n */\nexport function max(num: unknown, max: number): boolean {\n return typeof num === \"number\" && typeof max === \"number\" && num <= max;\n}\n\n/**\n * Checks if the first number is less than or equal to the second.\n */\nexport function Max(maxValue: number, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: MAX,\n constraints: [maxValue],\n validator: {\n validate: (value, args) => max(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must not be greater than $constraint1\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const MIN = "min";
/**
* Checks if the first number is greater than or equal to the second.
*/
export function min(num, min) {
return typeof num === "number" && typeof min === "number" && num >= min;
}
/**
* Checks if the first number is greater than or equal to the second.
*/
export function Min(minValue, validationOptions) {
return ValidateBy({
name: MIN,
constraints: [minValue],
validator: {
validate: (value, args) => min(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must not be less than $constraint1", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=Min.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/number/Min.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;AAEzB;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,GAAY,EAAE,GAAW;IACzC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,IAAI,GAAG,CAAC;AAC5E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAE,iBAAqC;IACvE,OAAO,UAAU,CACb;QACI,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC1D,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,8CAA8C,EAC3E,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"Min.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const MIN = \"min\";\n\n/**\n * Checks if the first number is greater than or equal to the second.\n */\nexport function min(num: unknown, min: number): boolean {\n return typeof num === \"number\" && typeof min === \"number\" && num >= min;\n}\n\n/**\n * Checks if the first number is greater than or equal to the second.\n */\nexport function Min(minValue: number, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: MIN,\n constraints: [minValue],\n validator: {\n validate: (value, args) => min(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must not be less than $constraint1\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,32 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
export const IS_INSTANCE = "isInstance";
/**
* Checks if the value is an instance of the specified object.
*/
export function isInstance(object, targetTypeConstructor) {
return targetTypeConstructor
&& typeof targetTypeConstructor === "function"
&& object instanceof targetTypeConstructor;
}
/**
* Checks if the value is an instance of the specified object.
*/
export function IsInstance(targetType, validationOptions) {
return ValidateBy({
name: IS_INSTANCE,
constraints: [targetType],
validator: {
validate: (value, args) => isInstance(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix, args) => {
if (args.constraints[0]) {
return eachPrefix + `$property must be an instance of ${args.constraints[0].name}`;
}
else {
return eachPrefix + `${IS_INSTANCE} decorator expects and object as value, but got falsy value.`;
}
}, validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsInstance.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/object/IsInstance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAAe,EAAE,qBAAkD;IAC1F,OAAO,qBAAqB;WACrB,OAAO,qBAAqB,KAAK,UAAU;WAC3C,MAAM,YAAY,qBAAqB,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,UAAuC,EAAE,iBAAqC;IACrG,OAAO,UAAU,CACb;QACI,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,CAAC,UAAU,CAAC;QACzB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACjE,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE;gBACjB,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE;oBACrB,OAAO,UAAU,GAAG,oCAAoC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;iBACtF;qBAAM;oBACH,OAAO,UAAU,GAAG,GAAG,WAAW,8DAA8D,CAAC;iBACpG;YACL,CAAC,EACD,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsInstance.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\n\nexport const IS_INSTANCE = \"isInstance\";\n\n/**\n * Checks if the value is an instance of the specified object.\n */\nexport function isInstance(object: unknown, targetTypeConstructor: new (...args: any[]) => any) {\n return targetTypeConstructor\n && typeof targetTypeConstructor === \"function\"\n && object instanceof targetTypeConstructor;\n}\n\n/**\n * Checks if the value is an instance of the specified object.\n */\nexport function IsInstance(targetType: new (...args: any[]) => any, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_INSTANCE,\n constraints: [targetType],\n validator: {\n validate: (value, args) => isInstance(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix, args) => {\n if (args.constraints[0]) {\n return eachPrefix + `$property must be an instance of ${args.constraints[0].name}`;\n } else {\n return eachPrefix + `${IS_INSTANCE} decorator expects and object as value, but got falsy value.`;\n }\n },\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,33 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
import { isObject } from "../typechecker/IsObject";
export const IS_NOT_EMPTY_OBJECT = "isNotEmptyObject";
/**
* Checks if the value is valid Object & not empty.
* Returns false if the value is not an object or an empty valid object.
*/
export function isNotEmptyObject(value) {
if (!isObject(value)) {
return false;
}
for (const key in value) {
if (value.hasOwnProperty(key)) {
return true;
}
}
return false;
}
/**
* Checks if the value is valid Object & not empty.
* Returns false if the value is not an object or an empty valid object.
*/
export function IsNotEmptyObject(validationOptions) {
return ValidateBy({
name: IS_NOT_EMPTY_OBJECT,
validator: {
validate: (value, args) => isNotEmptyObject(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be a non-empty object", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsNotEmptyObject.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/object/IsNotEmptyObject.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAEtD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC3C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC;KAChB;IACD,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE;QACrB,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;YAC3B,OAAO,IAAI,CAAC;SACf;KACJ;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,iBAAqC;IAClE,OAAO,UAAU,CACb;QACI,IAAI,EAAE,mBAAmB;QACzB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC;YAClD,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,sCAAsC,EACnE,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsNotEmptyObject.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\nimport { isObject } from \"../typechecker/IsObject\";\n\nexport const IS_NOT_EMPTY_OBJECT = \"isNotEmptyObject\";\n\n/**\n * Checks if the value is valid Object & not empty.\n * Returns false if the value is not an object or an empty valid object.\n */\nexport function isNotEmptyObject(value: unknown): boolean {\n if (!isObject(value)) {\n return false;\n }\n for (const key in value) {\n if (value.hasOwnProperty(key)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Checks if the value is valid Object & not empty.\n * Returns false if the value is not an object or an empty valid object.\n */\nexport function IsNotEmptyObject(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_NOT_EMPTY_OBJECT,\n validator: {\n validate: (value, args) => isNotEmptyObject(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be a non-empty object\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,26 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
import validator from "validator";
export const CONTAINS = "contains";
/**
* Checks if the string contains the seed.
* If given value is not a string, then it returns false.
*/
export function contains(value, seed) {
return typeof value === "string" && validator.contains(value, seed);
}
/**
* Checks if the string contains the seed.
* If given value is not a string, then it returns false.
*/
export function Contains(seed, validationOptions) {
return ValidateBy({
name: CONTAINS,
constraints: [seed],
validator: {
validate: (value, args) => contains(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must contain a $constraint1 string", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=Contains.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/string/Contains.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;AAEnC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc,EAAE,IAAY;IACjD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACxE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,iBAAqC;IACxE,OAAO,UAAU,CACb;QACI,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,CAAC,IAAI,CAAC;QACnB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC/D,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,8CAA8C,EAC3E,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"Contains.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\nimport validator from \"validator\";\n\nexport const CONTAINS = \"contains\";\n\n/**\n * Checks if the string contains the seed.\n * If given value is not a string, then it returns false.\n */\nexport function contains(value: unknown, seed: string): boolean {\n return typeof value === \"string\" && validator.contains(value, seed);\n}\n\n/**\n * Checks if the string contains the seed.\n * If given value is not a string, then it returns false.\n */\nexport function Contains(seed: string, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: CONTAINS,\n constraints: [seed],\n validator: {\n validate: (value, args) => contains(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must contain a $constraint1 string\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,26 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
import ValidatorJS from "validator";
export const IS_ALPHA = "isAlpha";
/**
* Checks if the string contains only letters (a-zA-Z).
* If given value is not a string, then it returns false.
*/
export function isAlpha(value, locale) {
return typeof value === "string" && ValidatorJS.isAlpha(value, locale);
}
/**
* Checks if the string contains only letters (a-zA-Z).
* If given value is not a string, then it returns false.
*/
export function IsAlpha(locale, validationOptions) {
return ValidateBy({
name: IS_ALPHA,
constraints: [locale],
validator: {
validate: (value, args) => isAlpha(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must contain only letters (a-zA-Z)", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsAlpha.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/string/IsAlpha.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,WAAW,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,MAAgC;IACpE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,MAAe,EAAE,iBAAqC;IAC1E,OAAO,UAAU,CACb;QACI,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC9D,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,8CAA8C,EAC3E,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsAlpha.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\nimport ValidatorJS from \"validator\";\n\nexport const IS_ALPHA = \"isAlpha\";\n\n/**\n * Checks if the string contains only letters (a-zA-Z).\n * If given value is not a string, then it returns false.\n */\nexport function isAlpha(value: unknown, locale?: ValidatorJS.AlphaLocale): boolean {\n return typeof value === \"string\" && ValidatorJS.isAlpha(value, locale);\n}\n\n/**\n * Checks if the string contains only letters (a-zA-Z).\n * If given value is not a string, then it returns false.\n */\nexport function IsAlpha(locale?: string, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_ALPHA,\n constraints: [locale],\n validator: {\n validate: (value, args) => isAlpha(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must contain only letters (a-zA-Z)\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,26 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
import ValidatorJS from "validator";
export const IS_ALPHANUMERIC = "isAlphanumeric";
/**
* Checks if the string contains only letters and numbers.
* If given value is not a string, then it returns false.
*/
export function isAlphanumeric(value, locale) {
return typeof value === "string" && ValidatorJS.isAlphanumeric(value, locale);
}
/**
* Checks if the string contains only letters and numbers.
* If given value is not a string, then it returns false.
*/
export function IsAlphanumeric(locale, validationOptions) {
return ValidateBy({
name: IS_ALPHANUMERIC,
constraints: [locale],
validator: {
validate: (value, args) => isAlphanumeric(value, args.constraints[0]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must contain only letters and numbers", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsAlphanumeric.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/string/IsAlphanumeric.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,WAAW,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAEhD;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,MAAuC;IAClF,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,WAAW,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAClF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAAe,EAAE,iBAAqC;IACjF,OAAO,UAAU,CACb;QACI,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACrE,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,iDAAiD,EAC9E,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsAlphanumeric.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\nimport ValidatorJS from \"validator\";\n\nexport const IS_ALPHANUMERIC = \"isAlphanumeric\";\n\n/**\n * Checks if the string contains only letters and numbers.\n * If given value is not a string, then it returns false.\n */\nexport function isAlphanumeric(value: unknown, locale?: ValidatorJS.AlphanumericLocale): boolean {\n return typeof value === \"string\" && ValidatorJS.isAlphanumeric(value, locale);\n}\n\n/**\n * Checks if the string contains only letters and numbers.\n * If given value is not a string, then it returns false.\n */\nexport function IsAlphanumeric(locale?: string, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_ALPHANUMERIC,\n constraints: [locale],\n validator: {\n validate: (value, args) => isAlphanumeric(value, args.constraints[0]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must contain only letters and numbers\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
import validator from "validator";
export const IS_ASCII = "isAscii";
/**
* Checks if the string contains ASCII chars only.
* If given value is not a string, then it returns false.
*/
export function isAscii(value) {
return typeof value === "string" && validator.isAscii(value);
}
/**
* Checks if the string contains ASCII chars only.
* If given value is not a string, then it returns false.
*/
export function IsAscii(validationOptions) {
return ValidateBy({
name: IS_ASCII,
validator: {
validate: (value, args) => isAscii(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must contain only ASCII characters", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsAscii.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/string/IsAscii.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,iBAAqC;IACzD,OAAO,UAAU,CACb;QACI,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;YACzC,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,8CAA8C,EAC3E,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsAscii.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\nimport validator from \"validator\";\n\nexport const IS_ASCII = \"isAscii\";\n\n/**\n * Checks if the string contains ASCII chars only.\n * If given value is not a string, then it returns false.\n */\nexport function isAscii(value: unknown): boolean {\n return typeof value === \"string\" && validator.isAscii(value);\n}\n\n/**\n * Checks if the string contains ASCII chars only.\n * If given value is not a string, then it returns false.\n */\nexport function IsAscii(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_ASCII,\n validator: {\n validate: (value, args) => isAscii(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must contain only ASCII characters\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
import validator from "validator";
export const IS_BIC = "isBIC";
/**
* Check if a string is a BIC (Bank Identification Code) or SWIFT code.
* If given value is not a string, then it returns false.
*/
export function isBIC(value) {
return typeof value === "string" && validator.isBIC(value);
}
/**
* Check if a string is a BIC (Bank Identification Code) or SWIFT code.
* If given value is not a string, then it returns false.
*/
export function IsBIC(validationOptions) {
return ValidateBy({
name: IS_BIC,
validator: {
validate: (value, args) => isBIC(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be a BIC or SWIFT code", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsBIC.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/string/IsBIC.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC;AAE9B;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,iBAAqC;IACvD,OAAO,UAAU,CACb;QACI,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;YACvC,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,uCAAuC,EACpE,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsBIC.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\nimport validator from \"validator\";\n\nexport const IS_BIC = \"isBIC\";\n\n/**\n * Check if a string is a BIC (Bank Identification Code) or SWIFT code.\n * If given value is not a string, then it returns false.\n */\nexport function isBIC(value: unknown): boolean {\n return typeof value === \"string\" && validator.isBIC(value);\n}\n\n/**\n * Check if a string is a BIC (Bank Identification Code) or SWIFT code.\n * If given value is not a string, then it returns false.\n */\nexport function IsBIC(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_BIC,\n validator: {\n validate: (value, args) => isBIC(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be a BIC or SWIFT code\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
import validator from "validator";
export const IS_BASE32 = "isBase32";
/**
* Checks if a string is base32 encoded.
* If given value is not a string, then it returns false.
*/
export function isBase32(value) {
return typeof value === "string" && validator.isBase32(value);
}
/**
* Check if a string is base32 encoded.
* If given value is not a string, then it returns false.
*/
export function IsBase32(validationOptions) {
return ValidateBy({
name: IS_BASE32,
validator: {
validate: (value, args) => isBase32(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be base32 encoded", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsBase32.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/string/IsBase32.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,iBAAqC;IAC1D,OAAO,UAAU,CACb;QACI,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC1C,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,kCAAkC,EAC/D,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsBase32.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\nimport validator from \"validator\";\n\nexport const IS_BASE32 = \"isBase32\";\n\n/**\n * Checks if a string is base32 encoded.\n * If given value is not a string, then it returns false.\n */\nexport function isBase32(value: unknown): boolean {\n return typeof value === \"string\" && validator.isBase32(value);\n}\n\n/**\n * Check if a string is base32 encoded.\n * If given value is not a string, then it returns false.\n */\nexport function IsBase32(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_BASE32,\n validator: {\n validate: (value, args) => isBase32(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be base32 encoded\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
import validator from "validator";
export const IS_BASE64 = "isBase64";
/**
* Checks if a string is base64 encoded.
* If given value is not a string, then it returns false.
*/
export function isBase64(value) {
return typeof value === "string" && validator.isBase64(value);
}
/**
* Checks if a string is base64 encoded.
* If given value is not a string, then it returns false.
*/
export function IsBase64(validationOptions) {
return ValidateBy({
name: IS_BASE64,
validator: {
validate: (value, args) => isBase64(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be base64 encoded", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsBase64.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/string/IsBase64.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,iBAAqC;IAC1D,OAAO,UAAU,CACb;QACI,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC1C,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,kCAAkC,EAC/D,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsBase64.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\nimport validator from \"validator\";\n\nexport const IS_BASE64 = \"isBase64\";\n\n/**\n * Checks if a string is base64 encoded.\n * If given value is not a string, then it returns false.\n */\nexport function isBase64(value: unknown): boolean {\n return typeof value === \"string\" && validator.isBase64(value);\n}\n\n/**\n * Checks if a string is base64 encoded.\n * If given value is not a string, then it returns false.\n */\nexport function IsBase64(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_BASE64,\n validator: {\n validate: (value, args) => isBase64(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be base64 encoded\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
import validator from "validator";
export const IS_BOOLEAN_STRING = "isBooleanString";
/**
* Checks if a string is a boolean.
* If given value is not a string, then it returns false.
*/
export function isBooleanString(value) {
return typeof value === "string" && validator.isBoolean(value);
}
/**
* Checks if a string is a boolean.
* If given value is not a string, then it returns false.
*/
export function IsBooleanString(validationOptions) {
return ValidateBy({
name: IS_BOOLEAN_STRING,
validator: {
validate: (value, args) => isBooleanString(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be a boolean string", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsBooleanString.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/string/IsBooleanString.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,iBAAqC;IACjE,OAAO,UAAU,CACb;QACI,IAAI,EAAE,iBAAiB;QACvB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC;YACjD,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,oCAAoC,EACjE,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsBooleanString.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\nimport validator from \"validator\";\n\nexport const IS_BOOLEAN_STRING = \"isBooleanString\";\n\n/**\n * Checks if a string is a boolean.\n * If given value is not a string, then it returns false.\n */\nexport function isBooleanString(value: unknown): boolean {\n return typeof value === \"string\" && validator.isBoolean(value);\n}\n\n/**\n * Checks if a string is a boolean.\n * If given value is not a string, then it returns false.\n */\nexport function IsBooleanString(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_BOOLEAN_STRING,\n validator: {\n validate: (value, args) => isBooleanString(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be a boolean string\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
import validator from "validator";
export const IS_BTC_ADDRESS = "isBtcAddress";
/**
* Check if the string is a valid BTC address.
* If given value is not a string, then it returns false.
*/
export function isBtcAddress(value) {
return typeof value === "string" && validator.isBtcAddress(value);
}
/**
* Check if the string is a valid BTC address.
* If given value is not a string, then it returns false.
*/
export function IsBtcAddress(validationOptions) {
return ValidateBy({
name: IS_BTC_ADDRESS,
validator: {
validate: (value, args) => isBtcAddress(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be a BTC address", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsBtcAddress.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/string/IsBtcAddress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,iBAAqC;IAC9D,OAAO,UAAU,CACb;QACI,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC;YAC9C,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,iCAAiC,EAC9D,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsBtcAddress.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\nimport validator from \"validator\";\n\nexport const IS_BTC_ADDRESS = \"isBtcAddress\";\n\n/**\n * Check if the string is a valid BTC address.\n * If given value is not a string, then it returns false.\n */\nexport function isBtcAddress(value: unknown): boolean {\n return typeof value === \"string\" && validator.isBtcAddress(value);\n}\n\n/**\n * Check if the string is a valid BTC address.\n * If given value is not a string, then it returns false.\n */\nexport function IsBtcAddress(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_BTC_ADDRESS,\n validator: {\n validate: (value, args) => isBtcAddress(value),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property must be a BTC address\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,26 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
import validator from "validator";
export const IS_BYTE_LENGTH = "isByteLength";
/**
* Checks if the string's length (in bytes) falls in a range.
* If given value is not a string, then it returns false.
*/
export function isByteLength(value, min, max) {
return typeof value === "string" && validator.isByteLength(value, { min, max });
}
/**
* Checks if the string's length (in bytes) falls in a range.
* If given value is not a string, then it returns false.
*/
export function IsByteLength(min, max, validationOptions) {
return ValidateBy({
name: IS_BYTE_LENGTH,
constraints: [min, max],
validator: {
validate: (value, args) => isByteLength(value, args.constraints[0], args.constraints[1]),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property's byte length must fall into ($constraint1, $constraint2) range", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsByteLength.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/decorator/string/IsByteLength.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,GAAW,EAAE,GAAY;IAClE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AACpF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,GAAY,EAAE,iBAAqC;IACzF,OAAO,UAAU,CACb;QACI,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;QACvB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACxF,cAAc,EAAE,YAAY,CACxB,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,2EAA2E,EACxG,iBAAiB,CACpB;SACJ;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC","file":"IsByteLength.js","sourcesContent":["import { ValidationOptions } from \"../ValidationOptions\";\nimport { buildMessage, ValidateBy } from \"../common/ValidateBy\";\nimport validator from \"validator\";\n\nexport const IS_BYTE_LENGTH = \"isByteLength\";\n\n/**\n * Checks if the string's length (in bytes) falls in a range.\n * If given value is not a string, then it returns false.\n */\nexport function isByteLength(value: unknown, min: number, max?: number): boolean {\n return typeof value === \"string\" && validator.isByteLength(value, { min, max });\n}\n\n/**\n * Checks if the string's length (in bytes) falls in a range.\n * If given value is not a string, then it returns false.\n */\nexport function IsByteLength(min: number, max?: number, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_BYTE_LENGTH,\n constraints: [min, max],\n validator: {\n validate: (value, args) => isByteLength(value, args.constraints[0], args.constraints[1]),\n defaultMessage: buildMessage(\n (eachPrefix) => eachPrefix + \"$property's byte length must fall into ($constraint1, $constraint2) range\",\n validationOptions\n )\n }\n },\n validationOptions\n );\n}\n"],"sourceRoot":"../.."}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from "../common/ValidateBy";
import validator from "validator";
export const IS_CREDIT_CARD = "isCreditCard";
/**
* Checks if the string is a credit card.
* If given value is not a string, then it returns false.
*/
export function isCreditCard(value) {
return typeof value === "string" && validator.isCreditCard(value);
}
/**
* Checks if the string is a credit card.
* If given value is not a string, then it returns false.
*/
export function IsCreditCard(validationOptions) {
return ValidateBy({
name: IS_CREDIT_CARD,
validator: {
validate: (value, args) => isCreditCard(value),
defaultMessage: buildMessage((eachPrefix) => eachPrefix + "$property must be a credit card", validationOptions)
}
}, validationOptions);
}
//# sourceMappingURL=IsCreditCard.js.map

Some files were not shown because too many files have changed in this diff Show More