backend v4 half

This commit is contained in:
2025-07-18 09:20:40 +02:00
parent aba7a506ad
commit 725516ad6c
4183 changed files with 217684 additions and 75056 deletions
+47
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.
*/
var defaultContainer = new (/** @class */ (function () {
function class_1() {
this.instances = [];
}
class_1.prototype.get = function (someClass) {
var instance = this.instances.find(function (instance) { return instance.type === someClass; });
if (!instance) {
instance = { type: someClass, object: new someClass() };
this.instances.push(instance);
}
return instance.object;
};
return class_1;
}()))();
var userContainer;
var 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 {
var 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
@@ -0,0 +1 @@
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/container.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,IAAM,gBAAgB,GAAqE,IAAI;IAAC;QACtF,cAAS,GAAsC,EAAE,CAAC;IAU5D,CAAC;IATC,qBAAG,GAAH,UAAO,SAAsC;QAC3C,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAA,QAAQ,IAAI,OAAA,QAAQ,CAAC,IAAI,KAAK,SAAS,EAA3B,CAA2B,CAAC,CAAC;QAC5E,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,QAAQ,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,SAAS,EAAE,EAAE,CAAC;YACxD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;IACH,cAAC;AAAD,CAAC,AAX+F,IAW9F,EAAE,CAAC;AAEL,IAAI,aAA+E,CAAC;AACpF,IAAI,oBAAyC,CAAC;AAE9C;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,YAA0C,EAAE,OAA6B;IACpG,aAAa,GAAG,YAAY,CAAC;IAC7B,oBAAoB,GAAG,OAAO,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAI,SAAiD;IACnF,IAAI,aAAa,EAAE,CAAC;QAClB,IAAI,CAAC;YACH,IAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC9C,IAAI,QAAQ;gBAAE,OAAO,QAAQ,CAAC;YAE9B,IAAI,CAAC,oBAAoB,IAAI,CAAC,oBAAoB,CAAC,QAAQ;gBAAE,OAAO,QAAQ,CAAC;QAC/E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,oBAAoB,IAAI,CAAC,oBAAoB,CAAC,gBAAgB;gBAAE,MAAM,KAAK,CAAC;QACnF,CAAC;IACH,CAAC;IACD,OAAO,gBAAgB,CAAC,GAAG,CAAI,SAAS,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["/**\n * Container options.\n */\nexport interface UseContainerOptions {\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 * 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): void {\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) return instance;\n\n if (!userContainerOptions || !userContainerOptions.fallback) return instance;\n } catch (error) {\n if (!userContainerOptions || !userContainerOptions.fallbackOnErrors) throw error;\n }\n }\n return defaultContainer.get<T>(someClass);\n}\n"]}
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
{"version":3,"file":"ValidationOptions.js","sourceRoot":"","sources":["../../../src/decorator/ValidationOptions.ts"],"names":[],"mappings":"AAiCA,MAAM,UAAU,mBAAmB,CAAC,GAAQ;IAC1C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,MAAM,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,IAAI,QAAQ,IAAI,GAAG,IAAI,QAAQ,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,CAAC;AACrG,CAAC","sourcesContent":["import { ValidationArguments } from '../validation/ValidationArguments';\n\n/**\n * Options used to pass to validation decorators.\n */\nexport interface ValidationOptions {\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\nexport function isValidationOptions(val: any): val is ValidationOptions {\n if (!val) {\n return false;\n }\n return 'each' in val || 'message' in val || 'groups' in val || 'always' in val || 'context' in val;\n}\n"]}
@@ -0,0 +1,26 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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.isArray(array))
return false;
return values.every(function (value) { return 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: function (value, args) { return arrayContains(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain $constraint1 values'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=ArrayContains.js.map
@@ -0,0 +1 @@
{"version":3,"file":"ArrayContains.js","sourceRoot":"","sources":["../../../../src/decorator/array/ArrayContains.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,cAAc,GAAG,eAAe,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,MAAa;IACzD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,OAAO,MAAM,CAAC,KAAK,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAA3B,CAA2B,CAAC,CAAC;AAC5D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAa,EAAE,iBAAqC;IAChF,OAAO,UAAU,CACf;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,aAAa,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAA1C,CAA0C;YAC9E,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,4CAA4C,EAAzD,CAAyD,EACvE,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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[]): boolean {\n if (!Array.isArray(array)) 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): boolean => 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"]}
@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var ARRAY_MAX_SIZE = 'arrayMaxSize';
/**
* Checks if the array's length is less or equal to the specified number.
* If null or undefined is given then this function returns false.
*/
export function arrayMaxSize(array, max) {
return Array.isArray(array) && array.length <= max;
}
/**
* Checks if the array's length is less or equal to the specified number.
* If null or undefined is given then this function returns false.
*/
export function ArrayMaxSize(max, validationOptions) {
return ValidateBy({
name: ARRAY_MAX_SIZE,
constraints: [max],
validator: {
validate: function (value, args) { return arrayMaxSize(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain no more than $constraint1 elements'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=ArrayMaxSize.js.map
@@ -0,0 +1 @@
{"version":3,"file":"ArrayMaxSize.js","sourceRoot":"","sources":["../../../../src/decorator/array/ArrayMaxSize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,cAAc,GAAG,cAAc,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,GAAW;IACtD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,iBAAqC;IAC7E,OAAO,UAAU,CACf;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,CAAC,GAAG,CAAC;QAClB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,YAAY,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAzC,CAAyC;YAC7E,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,2DAA2D,EAAxE,CAAwE,EACtF,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\n\nexport const ARRAY_MAX_SIZE = 'arrayMaxSize';\n\n/**\n * Checks if the array's length is less or equal to the specified number.\n * If null or undefined is given then this function returns false.\n */\nexport function arrayMaxSize(array: unknown, max: number): boolean {\n return Array.isArray(array) && array.length <= max;\n}\n\n/**\n * Checks if the array's length is less or equal to the specified 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): boolean => arrayMaxSize(value, args?.constraints[0]),\n defaultMessage: buildMessage(\n eachPrefix => eachPrefix + '$property must contain no more than $constraint1 elements',\n validationOptions\n ),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var ARRAY_MIN_SIZE = 'arrayMinSize';
/**
* Checks if the array's length is greater than or equal to the specified number.
* If null or undefined is given then this function returns false.
*/
export function arrayMinSize(array, min) {
return Array.isArray(array) && array.length >= min;
}
/**
* Checks if the array's length is greater than or equal to the specified number.
* If null or undefined is given then this function returns false.
*/
export function ArrayMinSize(min, validationOptions) {
return ValidateBy({
name: ARRAY_MIN_SIZE,
constraints: [min],
validator: {
validate: function (value, args) { return arrayMinSize(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain at least $constraint1 elements'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=ArrayMinSize.js.map
@@ -0,0 +1 @@
{"version":3,"file":"ArrayMinSize.js","sourceRoot":"","sources":["../../../../src/decorator/array/ArrayMinSize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,cAAc,GAAG,cAAc,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,GAAW;IACtD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,iBAAqC;IAC7E,OAAO,UAAU,CACf;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,CAAC,GAAG,CAAC;QAClB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,YAAY,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAzC,CAAyC;YAC7E,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,uDAAuD,EAApE,CAAoE,EAClF,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\n\nexport const ARRAY_MIN_SIZE = 'arrayMinSize';\n\n/**\n * Checks if the array's length is greater than or equal to the specified number.\n * If null or undefined is given then this function returns false.\n */\nexport function arrayMinSize(array: unknown, min: number): boolean {\n return Array.isArray(array) && array.length >= min;\n}\n\n/**\n * Checks if the array's length is greater than or equal to the specified 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): boolean => 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"]}
@@ -0,0 +1,26 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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.isArray(array))
return false;
return values.every(function (value) { return 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: function (value, args) { return arrayNotContains(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property should not contain $constraint1 values'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=ArrayNotContains.js.map
@@ -0,0 +1 @@
{"version":3,"file":"ArrayNotContains.js","sourceRoot":"","sources":["../../../../src/decorator/array/ArrayNotContains.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAErD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc,EAAE,MAAa;IAC5D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,OAAO,MAAM,CAAC,KAAK,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAA3B,CAA2B,CAAC,CAAC;AAC5D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAa,EAAE,iBAAqC;IACnF,OAAO,UAAU,CACf;QACE,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,gBAAgB,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAA7C,CAA6C;YACjF,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,kDAAkD,EAA/D,CAA+D,EAC7E,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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[]): boolean {\n if (!Array.isArray(array)) 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): boolean => 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"]}
@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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.isArray(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: function (value, args) { return arrayNotEmpty(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property should not be empty'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=ArrayNotEmpty.js.map
@@ -0,0 +1 @@
{"version":3,"file":"ArrayNotEmpty.js","sourceRoot":"","sources":["../../../../src/decorator/array/ArrayNotEmpty.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,eAAe,GAAG,eAAe,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,iBAAqC;IACjE,OAAO,UAAU,CACf;QACE,IAAI,EAAE,eAAe;QACrB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,aAAa,CAAC,KAAK,CAAC,EAApB,CAAoB;YACxD,cAAc,EAAE,YAAY,CAAC,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,+BAA+B,EAA5C,CAA4C,EAAE,iBAAiB,CAAC;SAC5G;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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): boolean {\n return Array.isArray(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): boolean => arrayNotEmpty(value),\n defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property should not be empty', validationOptions),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,31 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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, identifier) {
if (!Array.isArray(array))
return false;
if (identifier) {
array = array.map(function (o) { return (o != null ? identifier(o) : o); });
}
var uniqueItems = array.filter(function (a, b, c) { return 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(identifierOrOptions, validationOptions) {
var identifier = typeof identifierOrOptions === 'function' ? identifierOrOptions : undefined;
var options = typeof identifierOrOptions !== 'function' ? identifierOrOptions : validationOptions;
return ValidateBy({
name: ARRAY_UNIQUE,
validator: {
validate: function (value, args) { return arrayUnique(value, identifier); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + "All $property's elements must be unique"; }, options),
},
}, options);
}
//# sourceMappingURL=ArrayUnique.js.map
@@ -0,0 +1 @@
{"version":3,"file":"ArrayUnique.js","sourceRoot":"","sources":["../../../../src/decorator/array/ArrayUnique.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,YAAY,GAAG,aAAa,CAAC;AAG1C;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAgB,EAAE,UAAkC;IAC9E,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,IAAI,UAAU,EAAE,CAAC;QACf,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAA/B,CAA+B,CAAC,CAAC;IAC1D,CAAC;IAED,IAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,EAAlB,CAAkB,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,mBAAkE,EAClE,iBAAqC;IAErC,IAAM,UAAU,GAAG,OAAO,mBAAmB,KAAK,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/F,IAAM,OAAO,GAAG,OAAO,mBAAmB,KAAK,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAEpG,OAAO,UAAU,CACf;QACE,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,EAA9B,CAA8B;YAClE,cAAc,EAAE,YAAY,CAAC,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,yCAAyC,EAAtD,CAAsD,EAAE,OAAO,CAAC;SAC5G;KACF,EACD,OAAO,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\n\nexport const ARRAY_UNIQUE = 'arrayUnique';\nexport type ArrayUniqueIdentifier<T = any> = (o: T) => any;\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[], identifier?: ArrayUniqueIdentifier): boolean {\n if (!Array.isArray(array)) return false;\n\n if (identifier) {\n array = array.map(o => (o != null ? identifier(o) : o));\n }\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<T = any>(\n identifierOrOptions?: ArrayUniqueIdentifier<T> | ValidationOptions,\n validationOptions?: ValidationOptions\n): PropertyDecorator {\n const identifier = typeof identifierOrOptions === 'function' ? identifierOrOptions : undefined;\n const options = typeof identifierOrOptions !== 'function' ? identifierOrOptions : validationOptions;\n\n return ValidateBy(\n {\n name: ARRAY_UNIQUE,\n validator: {\n validate: (value, args): boolean => arrayUnique(value, identifier),\n defaultMessage: buildMessage(eachPrefix => eachPrefix + \"All $property's elements must be unique\", options),\n },\n },\n options\n );\n}\n"]}
@@ -0,0 +1,18 @@
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) {
var args = {
type: ValidationTypes.WHITELIST,
target: object.constructor,
propertyName: propertyName,
validationOptions: validationOptions,
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=Allow.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Allow.js","sourceRoot":"","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;IACzD,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,IAAM,IAAI,GAA2B;YACnC,IAAI,EAAE,eAAe,CAAC,SAAS;YAC/B,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,iBAAiB,EAAE,iBAAiB;SACrC,CAAC;QACF,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC","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): void {\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"]}
@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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: function (value, args) { return equals(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be equal to $constraint1'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=Equals.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Equals.js","sourceRoot":"","sources":["../../../../src/decorator/common/Equals.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,MAAM,GAAG,QAAQ,CAAC;AAE/B;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc,EAAE,UAAmB;IACxD,OAAO,KAAK,KAAK,UAAU,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,UAAe,EAAE,iBAAqC;IAC3E,OAAO,UAAU,CACf;QACE,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,CAAC,UAAU,CAAC;QACzB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,MAAM,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAnC,CAAmC;YACvE,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,yCAAyC,EAAtD,CAAsD,EACpE,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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): boolean => 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"]}
@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from './ValidateBy';
import { ValidationTypes } from '../../validation/ValidationTypes';
// isDefined is (yet) a special case
export var 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: function (value) { return isDefined(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property should not be null or undefined'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsDefined.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsDefined.js","sourceRoot":"","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,IAAM,UAAU,GAAG,eAAe,CAAC,UAAU,CAAC;AAErD;;GAEG;AACH,MAAM,UAAU,SAAS,CAAI,KAA2B;IACtD,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,iBAAqC;IAC7D,OAAO,UAAU,CACf;QACE,IAAI,EAAE,UAAU;QAChB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,IAAc,OAAA,SAAS,CAAC,KAAK,CAAC,EAAhB,CAAgB;YAC9C,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,2CAA2C,EAAxD,CAAwD,EACtE,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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<T>(value: T | undefined | null): value is T {\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): boolean => 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"]}
@@ -0,0 +1,21 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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: function (value, args) { return isEmpty(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be empty'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsEmpty.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsEmpty.js","sourceRoot":"","sources":["../../../../src/decorator/common/IsEmpty.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,QAAQ,GAAG,SAAS,CAAC;AAElC;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,iBAAqC;IAC3D,OAAO,UAAU,CACf;QACE,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,OAAO,CAAC,KAAK,CAAC,EAAd,CAAc;YAClD,cAAc,EAAE,YAAY,CAAC,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,yBAAyB,EAAtC,CAAsC,EAAE,iBAAiB,CAAC;SACtG;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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): boolean => isEmpty(value),\n defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be empty', validationOptions),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var IS_IN = 'isIn';
/**
* Checks if given value is in a array of allowed values.
*/
export function isIn(value, possibleValues) {
return Array.isArray(possibleValues) && possibleValues.some(function (possibleValue) { return 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: function (value, args) { return isIn(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be one of the following values: $constraint1'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsIn.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsIn.js","sourceRoot":"","sources":["../../../../src/decorator/common/IsIn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,KAAK,GAAG,MAAM,CAAC;AAE5B;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,KAAc,EAAE,cAAkC;IACrE,OAAO,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,UAAA,aAAa,IAAI,OAAA,aAAa,KAAK,KAAK,EAAvB,CAAuB,CAAC,CAAC;AACxG,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,MAAsB,EAAE,iBAAqC;IAChF,OAAO,UAAU,CACf;QACE,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,IAAI,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAjC,CAAiC;YACrE,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,6DAA6D,EAA1E,CAA0E,EACxF,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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: readonly unknown[]): boolean {\n return Array.isArray(possibleValues) && 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: readonly any[], validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_IN,\n constraints: [values],\n validator: {\n validate: (value, args): boolean => 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"]}
@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from './ValidateBy';
import isLatLongValidator from 'validator/lib/isLatLong';
export var IS_LATLONG = 'isLatLong';
/**
* Checks if a value is string in format a "latitude,longitude".
*/
export function isLatLong(value) {
return typeof value === 'string' && isLatLongValidator(value);
}
/**
* Checks if a value is string in format a "latitude,longitude".
*/
export function IsLatLong(validationOptions) {
return ValidateBy({
name: IS_LATLONG,
validator: {
validate: function (value, args) { return isLatLong(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a latitude,longitude string'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsLatLong.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsLatLong.js","sourceRoot":"","sources":["../../../../src/decorator/common/IsLatLong.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AAEzD,MAAM,CAAC,IAAM,UAAU,GAAG,WAAW,CAAC;AAEtC;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,iBAAqC;IAC7D,OAAO,UAAU,CACf;QACE,IAAI,EAAE,UAAU;QAChB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,SAAS,CAAC,KAAK,CAAC,EAAhB,CAAgB;YACpD,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,+CAA+C,EAA5D,CAA4D,EAC1E,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from './ValidateBy';\nimport isLatLongValidator from 'validator/lib/isLatLong';\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' && isLatLongValidator(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): boolean => 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"]}
@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from './ValidateBy';
import { isLatLong } from './IsLatLong';
export var IS_LATITUDE = 'isLatitude';
/**
* Checks if a given value is a latitude.
*/
export function isLatitude(value) {
return (typeof value === 'number' || typeof value === 'string') && isLatLong("".concat(value, ",0"));
}
/**
* Checks if a given value is a latitude.
*/
export function IsLatitude(validationOptions) {
return ValidateBy({
name: IS_LATITUDE,
validator: {
validate: function (value, args) { return isLatitude(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a latitude string or number'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsLatitude.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsLatitude.js","sourceRoot":"","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,IAAM,WAAW,GAAG,YAAY,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,IAAI,SAAS,CAAC,UAAG,KAAK,OAAI,CAAC,CAAC;AAC7F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,iBAAqC;IAC9D,OAAO,UAAU,CACf;QACE,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,UAAU,CAAC,KAAK,CAAC,EAAjB,CAAiB;YACrD,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,+CAA+C,EAA5D,CAA4D,EAC1E,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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): boolean => 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"]}
@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from './ValidateBy';
import { isLatLong } from './IsLatLong';
export var IS_LONGITUDE = 'isLongitude';
/**
* Checks if a given value is a longitude.
*/
export function isLongitude(value) {
return (typeof value === 'number' || typeof value === 'string') && isLatLong("0,".concat(value));
}
/**
* Checks if a given value is a longitude.
*/
export function IsLongitude(validationOptions) {
return ValidateBy({
name: IS_LONGITUDE,
validator: {
validate: function (value, args) { return isLongitude(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a longitude string or number'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsLongitude.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsLongitude.js","sourceRoot":"","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,IAAM,YAAY,GAAG,aAAa,CAAC;AAE1C;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,IAAI,SAAS,CAAC,YAAK,KAAK,CAAE,CAAC,CAAC;AAC7F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,iBAAqC;IAC/D,OAAO,UAAU,CACf;QACE,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,WAAW,CAAC,KAAK,CAAC,EAAlB,CAAkB;YACtD,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,gDAAgD,EAA7D,CAA6D,EAC3E,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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): boolean => 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"]}
@@ -0,0 +1,21 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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: function (value, args) { return isNotEmpty(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property should not be empty'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsNotEmpty.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsNotEmpty.js","sourceRoot":"","sources":["../../../../src/decorator/common/IsNotEmpty.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,YAAY,GAAG,YAAY,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,iBAAqC;IAC9D,OAAO,UAAU,CACf;QACE,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,UAAU,CAAC,KAAK,CAAC,EAAjB,CAAiB;YACrD,cAAc,EAAE,YAAY,CAAC,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,+BAA+B,EAA5C,CAA4C,EAAE,iBAAiB,CAAC;SAC5G;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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): boolean => isNotEmpty(value),\n defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property should not be empty', validationOptions),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var IS_NOT_IN = 'isNotIn';
/**
* Checks if given value not in a array of allowed values.
*/
export function isNotIn(value, possibleValues) {
return !Array.isArray(possibleValues) || !possibleValues.some(function (possibleValue) { return 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: function (value, args) { return isNotIn(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property should not be one of the following values: $constraint1'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsNotIn.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsNotIn.js","sourceRoot":"","sources":["../../../../src/decorator/common/IsNotIn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,SAAS,GAAG,SAAS,CAAC;AAEnC;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,cAAkC;IACxE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,UAAA,aAAa,IAAI,OAAA,aAAa,KAAK,KAAK,EAAvB,CAAuB,CAAC,CAAC;AAC1G,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,MAAsB,EAAE,iBAAqC;IACnF,OAAO,UAAU,CACf;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,OAAO,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAApC,CAAoC;YACxE,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,mEAAmE,EAAhF,CAAgF,EAC9F,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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: readonly unknown[]): boolean {\n return !Array.isArray(possibleValues) || !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: readonly any[], validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_NOT_IN,\n constraints: [values],\n validator: {\n validate: (value, args): boolean => 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"]}
@@ -0,0 +1,25 @@
import { ValidationTypes } from '../../validation/ValidationTypes';
import { ValidationMetadata } from '../../metadata/ValidationMetadata';
import { getMetadataStorage } from '../../metadata/MetadataStorage';
export var IS_OPTIONAL = 'isOptional';
/**
* Checks if value is missing and if so, ignores all validators.
*/
export function IsOptional(validationOptions) {
return function (object, propertyName) {
var args = {
type: ValidationTypes.CONDITIONAL_VALIDATION,
name: IS_OPTIONAL,
target: object.constructor,
propertyName: propertyName,
constraints: [
function (object, value) {
return object[propertyName] !== null && object[propertyName] !== undefined;
},
],
validationOptions: validationOptions,
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=IsOptional.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsOptional.js","sourceRoot":"","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,MAAM,CAAC,IAAM,WAAW,GAAG,YAAY,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,iBAAqC;IAC9D,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,IAAM,IAAI,GAA2B;YACnC,IAAI,EAAE,eAAe,CAAC,sBAAsB;YAC5C,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,WAAW,EAAE;gBACX,UAAC,MAAW,EAAE,KAAU;oBACtB,OAAO,MAAM,CAAC,YAAY,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,SAAS,CAAC;gBAC7E,CAAC;aACF;YACD,iBAAiB,EAAE,iBAAiB;SACrC,CAAC;QACF,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC","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\nexport const IS_OPTIONAL = 'isOptional';\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): void {\n const args: ValidationMetadataArgs = {\n type: ValidationTypes.CONDITIONAL_VALIDATION,\n name: IS_OPTIONAL,\n target: object.constructor,\n propertyName: propertyName,\n constraints: [\n (object: any, value: any): boolean => {\n return object[propertyName] !== null && object[propertyName] !== undefined;\n },\n ],\n validationOptions: validationOptions,\n };\n getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));\n };\n}\n"]}
@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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: function (value, args) { return notEquals(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property should not be equal to $constraint1'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=NotEquals.js.map
@@ -0,0 +1 @@
{"version":3,"file":"NotEquals.js","sourceRoot":"","sources":["../../../../src/decorator/common/NotEquals.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,UAAU,GAAG,WAAW,CAAC;AAEtC;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,UAAmB;IAC3D,OAAO,KAAK,KAAK,UAAU,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,UAAe,EAAE,iBAAqC;IAC9E,OAAO,UAAU,CACf;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,CAAC,UAAU,CAAC;QACzB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,SAAS,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAtC,CAAsC;YAC1E,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,+CAA+C,EAA5D,CAA4D,EAC1E,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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): boolean => 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"]}
@@ -0,0 +1,37 @@
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) {
var isAsync = options && options.async;
var 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, function (x, y) { return '_' + y.toLowerCase(); }).replace(/^_/, '');
}
var metadata = new ConstraintMetadata(target, name, isAsync);
getMetadataStorage().addConstraintMetadata(metadata);
};
}
export function Validate(constraintClass, constraintsOrValidationOptions, maybeValidationOptions) {
return function (object, propertyName) {
var args = {
type: ValidationTypes.CUSTOM_VALIDATION,
target: object.constructor,
propertyName: propertyName,
constraintCls: constraintClass,
constraints: Array.isArray(constraintsOrValidationOptions) ? constraintsOrValidationOptions : undefined,
validationOptions: !Array.isArray(constraintsOrValidationOptions)
? constraintsOrValidationOptions
: maybeValidationOptions,
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=Validate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Validate.js","sourceRoot":"","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;IAC9E,OAAO,UAAU,MAAgB;QAC/B,IAAM,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC;QACzC,IAAI,IAAI,GAAG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,GAAI,MAAc,CAAC,IAAI,CAAC;YAC5B,IAAI,CAAC,IAAI;gBACP,oCAAoC;gBACpC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,GAAG,GAAI,CAAY,CAAC,WAAW,EAAE,EAAjC,CAAiC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACvG,CAAC;QACD,IAAM,QAAQ,GAAG,IAAI,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/D,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC;AAYD,MAAM,UAAU,QAAQ,CACtB,eAAyB,EACzB,8BAA0D,EAC1D,sBAA0C;IAE1C,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,IAAM,IAAI,GAA2B;YACnC,IAAI,EAAE,eAAe,CAAC,iBAAiB;YACvC,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,aAAa,EAAE,eAAe;YAC9B,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,SAAS;YACvG,iBAAiB,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,8BAA8B,CAAC;gBAC/D,CAAC,CAAC,8BAA8B;gBAChC,CAAC,CAAC,sBAAsB;SAC3B,CAAC;QACF,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC","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): void {\n const isAsync = options && options.async;\n let name = options && options.name ? options.name : '';\n if (!name) {\n name = (target as any).name;\n if (!name)\n // generate name if it was not given\n name = name.replace(/\\.?([A-Z]+)/g, (x, y) => '_' + (y as string).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(\n constraintClass: Function,\n constraints?: any[],\n validationOptions?: ValidationOptions\n): PropertyDecorator;\nexport function Validate(\n constraintClass: Function,\n constraintsOrValidationOptions?: any[] | ValidationOptions,\n maybeValidationOptions?: ValidationOptions\n): PropertyDecorator {\n return function (object: object, propertyName: string): void {\n const args: ValidationMetadataArgs = {\n type: ValidationTypes.CUSTOM_VALIDATION,\n target: object.constructor,\n propertyName: propertyName,\n constraintCls: constraintClass,\n constraints: Array.isArray(constraintsOrValidationOptions) ? constraintsOrValidationOptions : undefined,\n validationOptions: !Array.isArray(constraintsOrValidationOptions)\n ? constraintsOrValidationOptions\n : maybeValidationOptions,\n };\n getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));\n };\n}\n"]}
@@ -0,0 +1,20 @@
import { registerDecorator } from '../../register-decorator';
export function buildMessage(impl, validationOptions) {
return function (validationArguments) {
var 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
@@ -0,0 +1 @@
{"version":3,"file":"ValidateBy.js","sourceRoot":"","sources":["../../../../src/decorator/common/ValidateBy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAW7D,MAAM,UAAU,YAAY,CAC1B,IAAgE,EAChE,iBAAqC;IAErC,OAAO,UAAC,mBAAyC;QAC/C,IAAM,UAAU,GAAG,iBAAiB,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;QACvF,OAAO,IAAI,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;IAC/C,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,OAA0B,EAAE,iBAAqC;IAC1F,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,iBAAiB,CAAC;YAChB,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;SAC7B,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","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): string => {\n const eachPrefix = validationOptions && validationOptions.each ? 'each value in ' : '';\n return impl(eachPrefix, validationArguments);\n };\n}\n\nexport function ValidateBy(options: ValidateByOptions, validationOptions?: ValidationOptions): PropertyDecorator {\n return function (object: object, propertyName: string): void {\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"]}
@@ -0,0 +1,19 @@
import { ValidationTypes } from '../../validation/ValidationTypes';
import { ValidationMetadata } from '../../metadata/ValidationMetadata';
import { getMetadataStorage } from '../../metadata/MetadataStorage';
/**
* Ignores the other validators on a property when the provided condition function returns false.
*/
export function ValidateIf(condition, validationOptions) {
return function (object, propertyName) {
var args = {
type: ValidationTypes.CONDITIONAL_VALIDATION,
target: object.constructor,
propertyName: propertyName,
constraints: [condition],
validationOptions: validationOptions,
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=ValidateIf.js.map
@@ -0,0 +1 @@
{"version":3,"file":"ValidateIf.js","sourceRoot":"","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,CACxB,SAA+C,EAC/C,iBAAqC;IAErC,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,IAAM,IAAI,GAA2B;YACnC,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;SACrC,CAAC;QACF,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC","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 * Ignores the other validators on a property when the provided condition function returns false.\n */\nexport function ValidateIf(\n condition: (object: any, value: any) => boolean,\n validationOptions?: ValidationOptions\n): PropertyDecorator {\n return function (object: object, propertyName: string): void {\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"]}
@@ -0,0 +1,32 @@
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
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) {
var opts = __assign({}, validationOptions);
var eachPrefix = opts.each ? 'each value in ' : '';
opts.message = opts.message || eachPrefix + 'nested property $property must be either object or array';
return function (object, propertyName) {
var args = {
type: ValidationTypes.NESTED_VALIDATION,
target: object.constructor,
propertyName: propertyName,
validationOptions: opts,
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=ValidateNested.js.map
@@ -0,0 +1 @@
{"version":3,"file":"ValidateNested.js","sourceRoot":"","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;IAClE,IAAM,IAAI,gBAA2B,iBAAiB,CAAE,CAAC;IACzD,IAAM,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;QACnD,IAAM,IAAI,GAA2B;YACnC,IAAI,EAAE,eAAe,CAAC,iBAAiB;YACvC,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,iBAAiB,EAAE,IAAI;SACxB,CAAC;QACF,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC","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): void {\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"]}
@@ -0,0 +1,18 @@
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) {
var args = {
type: ValidationTypes.PROMISE_VALIDATION,
target: object.constructor,
propertyName: propertyName,
validationOptions: validationOptions,
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=ValidatePromise.js.map
@@ -0,0 +1 @@
{"version":3,"file":"ValidatePromise.js","sourceRoot":"","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;IACnE,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,IAAM,IAAI,GAA2B;YACnC,IAAI,EAAE,eAAe,CAAC,kBAAkB;YACxC,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,iBAAiB,EAAE,iBAAiB;SACrC,CAAC;QACF,kBAAkB,EAAE,CAAC,qBAAqB,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC","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): void {\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"]}
@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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 instanceof Date ? maxDate : maxDate()).getTime();
}
/**
* Checks if the value is a date that's before the specified date.
*/
export function MaxDate(date, validationOptions) {
return ValidateBy({
name: MAX_DATE,
constraints: [date],
validator: {
validate: function (value, args) { return maxDate(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return 'maximal allowed date for ' + eachPrefix + '$property is $constraint1'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=MaxDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"MaxDate.js","sourceRoot":"","sources":["../../../../src/decorator/date/MaxDate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,QAAQ,GAAG,SAAS,CAAC;AAElC;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,IAAa,EAAE,OAA4B;IACjE,OAAO,IAAI,YAAY,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,YAAY,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;AAC7G,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,IAAyB,EAAE,iBAAqC;IACtF,OAAO,UAAU,CACf;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,CAAC,IAAI,CAAC;QACnB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,OAAO,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAApC,CAAoC;YACxE,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,2BAA2B,GAAG,UAAU,GAAG,2BAA2B,EAAtE,CAAsE,EACpF,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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 | (() => Date)): boolean {\n return date instanceof Date && date.getTime() <= (maxDate instanceof Date ? maxDate : maxDate()).getTime();\n}\n\n/**\n * Checks if the value is a date that's before the specified date.\n */\nexport function MaxDate(date: Date | (() => Date), validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: MAX_DATE,\n constraints: [date],\n validator: {\n validate: (value, args): boolean => 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"]}
@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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 instanceof Date ? minDate : 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: function (value, args) { return minDate(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return 'minimal allowed date for ' + eachPrefix + '$property is $constraint1'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=MinDate.js.map
@@ -0,0 +1 @@
{"version":3,"file":"MinDate.js","sourceRoot":"","sources":["../../../../src/decorator/date/MinDate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,QAAQ,GAAG,SAAS,CAAC;AAElC;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,IAAa,EAAE,OAA4B;IACjE,OAAO,IAAI,YAAY,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,YAAY,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;AAC7G,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,IAAyB,EAAE,iBAAqC;IACtF,OAAO,UAAU,CACf;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,CAAC,IAAI,CAAC;QACnB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,OAAO,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAApC,CAAoC;YACxE,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,2BAA2B,GAAG,UAAU,GAAG,2BAA2B,EAAtE,CAAsE,EACpF,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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 | (() => Date)): boolean {\n return date instanceof Date && date.getTime() >= (minDate instanceof Date ? minDate : 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 | (() => Date), validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: MIN_DATE,\n constraints: [date],\n validator: {\n validate: (value, args): boolean => 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"]}
@@ -0,0 +1,136 @@
// -------------------------------------------------------------------------
// 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';
export * from './string/IsStrongPassword';
export * from './string/IsTimeZone';
export * from './string/IsBase58';
export * from './string/is-tax-id';
export * from './string/is-iso4217-currency-code';
// -------------------------------------------------------------------------
// 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
@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isDivisibleByValidator from 'validator/lib/isDivisibleBy';
export var 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' && isDivisibleByValidator(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: function (value, args) { return isDivisibleBy(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be divisible by $constraint1'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsDivisibleBy.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsDivisibleBy.js","sourceRoot":"","sources":["../../../../src/decorator/number/IsDivisibleBy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,sBAAsB,MAAM,6BAA6B,CAAC;AAEjE,MAAM,CAAC,IAAM,eAAe,GAAG,eAAe,CAAC;AAE/C;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,GAAW;IACvD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,sBAAsB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;AAC5G,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,iBAAqC;IAC9E,OAAO,UAAU,CACf;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,CAAC,GAAG,CAAC;QAClB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,aAAa,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAA1C,CAA0C;YAC9E,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,6CAA6C,EAA1D,CAA0D,EACxE,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isDivisibleByValidator from 'validator/lib/isDivisibleBy';\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' && typeof num === 'number' && isDivisibleByValidator(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): boolean => 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"]}
@@ -0,0 +1,21 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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: function (value, args) { return isNegative(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a negative number'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsNegative.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsNegative.js","sourceRoot":"","sources":["../../../../src/decorator/number/IsNegative.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,WAAW,GAAG,YAAY,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,iBAAqC;IAC9D,OAAO,UAAU,CACf;QACE,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,UAAU,CAAC,KAAK,CAAC,EAAjB,CAAiB;YACrD,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,qCAAqC,EAAlD,CAAkD,EAChE,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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): boolean => isNegative(value),\n defaultMessage: buildMessage(\n eachPrefix => eachPrefix + '$property must be a negative number',\n validationOptions\n ),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,21 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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: function (value, args) { return isPositive(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a positive number'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsPositive.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsPositive.js","sourceRoot":"","sources":["../../../../src/decorator/number/IsPositive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,WAAW,GAAG,YAAY,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,iBAAqC;IAC9D,OAAO,UAAU,CACf;QACE,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,UAAU,CAAC,KAAK,CAAC,EAAjB,CAAiB;YACrD,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,qCAAqC,EAAlD,CAAkD,EAChE,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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): boolean => isPositive(value),\n defaultMessage: buildMessage(\n eachPrefix => eachPrefix + '$property must be a positive number',\n validationOptions\n ),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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 value is less than or equal to the allowed maximum value.
*/
export function Max(maxValue, validationOptions) {
return ValidateBy({
name: MAX,
constraints: [maxValue],
validator: {
validate: function (value, args) { return max(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must not be greater than $constraint1'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=Max.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Max.js","sourceRoot":"","sources":["../../../../src/decorator/number/Max.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,GAAG,GAAG,KAAK,CAAC;AAEzB;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,GAAY,EAAE,GAAW;IAC3C,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,IAAI,GAAG,CAAC;AAC1E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAE,iBAAqC;IACzE,OAAO,UAAU,CACf;QACE,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,GAAG,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAhC,CAAgC;YACpE,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,iDAAiD,EAA9D,CAA8D,EAC5E,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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 value is less than or equal to the allowed maximum value.\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): boolean => 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"]}
@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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 value is greater than or equal to the allowed minimum value.
*/
export function Min(minValue, validationOptions) {
return ValidateBy({
name: MIN,
constraints: [minValue],
validator: {
validate: function (value, args) { return min(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must not be less than $constraint1'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=Min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Min.js","sourceRoot":"","sources":["../../../../src/decorator/number/Min.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,GAAG,GAAG,KAAK,CAAC;AAEzB;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,GAAY,EAAE,GAAW;IAC3C,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,IAAI,GAAG,CAAC;AAC1E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAE,iBAAqC;IACzE,OAAO,UAAU,CACf;QACE,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,GAAG,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAhC,CAAgC;YACpE,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,8CAA8C,EAA3D,CAA2D,EACzE,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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 value is greater than or equal to the allowed minimum value.\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): boolean => 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"]}
@@ -0,0 +1,29 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export var 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: function (value, args) { return isInstance(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix, args) {
if (args === null || args === void 0 ? void 0 : args.constraints[0]) {
return eachPrefix + "$property must be an instance of ".concat(args === null || args === void 0 ? void 0 : args.constraints[0].name);
}
else {
return eachPrefix + "".concat(IS_INSTANCE, " decorator expects and object as value, but got falsy value.");
}
}, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsInstance.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsInstance.js","sourceRoot":"","sources":["../../../../src/decorator/object/IsInstance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,CAAC,IAAM,WAAW,GAAG,YAAY,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAAe,EAAE,qBAAkD;IAC5F,OAAO,CACL,qBAAqB,IAAI,OAAO,qBAAqB,KAAK,UAAU,IAAI,MAAM,YAAY,qBAAqB,CAChH,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CACxB,UAAuC,EACvC,iBAAqC;IAErC,OAAO,UAAU,CACf;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,CAAC,UAAU,CAAC;QACzB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,UAAU,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAvC,CAAuC;YAC3E,cAAc,EAAE,YAAY,CAAC,UAAC,UAAU,EAAE,IAAI;gBAC5C,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;oBACzB,OAAO,UAAU,GAAG,2CAAoC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,EAAE,IAAc,CAAE,CAAC;gBAChG,CAAC;qBAAM,CAAC;oBACN,OAAO,UAAU,GAAG,UAAG,WAAW,iEAA8D,CAAC;gBACnG,CAAC;YACH,CAAC,EAAE,iBAAiB,CAAC;SACtB;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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): boolean {\n return (\n targetTypeConstructor && typeof targetTypeConstructor === 'function' && object instanceof targetTypeConstructor\n );\n}\n\n/**\n * Checks if the value is an instance of the specified object.\n */\nexport function IsInstance(\n targetType: new (...args: any[]) => any,\n validationOptions?: ValidationOptions\n): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_INSTANCE,\n constraints: [targetType],\n validator: {\n validate: (value, args): boolean => isInstance(value, args?.constraints[0]),\n defaultMessage: buildMessage((eachPrefix, args) => {\n if (args?.constraints[0]) {\n return eachPrefix + `$property must be an instance of ${args?.constraints[0].name as string}`;\n } else {\n return eachPrefix + `${IS_INSTANCE} decorator expects and object as value, but got falsy value.`;\n }\n }, validationOptions),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,36 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import { isObject } from '../typechecker/IsObject';
export var 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, options) {
if (!isObject(value)) {
return false;
}
if ((options === null || options === void 0 ? void 0 : options.nullable) === false) {
return !Object.values(value).every(function (propertyValue) { return propertyValue === null || propertyValue === undefined; });
}
for (var 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(options, validationOptions) {
return ValidateBy({
name: IS_NOT_EMPTY_OBJECT,
constraints: [options],
validator: {
validate: function (value, args) { return isNotEmptyObject(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a non-empty object'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsNotEmptyObject.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsNotEmptyObject.js","sourceRoot":"","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,IAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAEtD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc,EAAE,OAAgC;IAC/E,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,MAAK,KAAK,EAAE,CAAC;QAChC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,UAAA,aAAa,IAAI,OAAA,aAAa,KAAK,IAAI,IAAI,aAAa,KAAK,SAAS,EAArD,CAAqD,CAAC,CAAC;IAC7G,CAAC;IAED,KAAK,IAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAgC,EAChC,iBAAqC;IAErC,OAAO,UAAU,CACf;QACE,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,CAAC,OAAO,CAAC;QACtB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,gBAAgB,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAA7C,CAA6C;YACjF,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,sCAAsC,EAAnD,CAAmD,EACjE,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","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, options?: { nullable?: boolean }): boolean {\n if (!isObject(value)) {\n return false;\n }\n\n if (options?.nullable === false) {\n return !Object.values(value).every(propertyValue => propertyValue === null || propertyValue === undefined);\n }\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(\n options?: { nullable?: boolean },\n validationOptions?: ValidationOptions\n): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_NOT_EMPTY_OBJECT,\n constraints: [options],\n validator: {\n validate: (value, args): boolean => isNotEmptyObject(value, args?.constraints[0]),\n defaultMessage: buildMessage(\n eachPrefix => eachPrefix + '$property must be a non-empty object',\n validationOptions\n ),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import containsValidator from 'validator/lib/contains';
export var 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' && containsValidator(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: function (value, args) { return contains(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain a $constraint1 string'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=Contains.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Contains.js","sourceRoot":"","sources":["../../../../src/decorator/string/Contains.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAEvD,MAAM,CAAC,IAAM,QAAQ,GAAG,UAAU,CAAC;AAEnC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc,EAAE,IAAY;IACnD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,iBAAqC;IAC1E,OAAO,UAAU,CACf;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,CAAC,IAAI,CAAC;QACnB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,QAAQ,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAArC,CAAqC;YACzE,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,8CAA8C,EAA3D,CAA2D,EACzE,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport containsValidator from 'validator/lib/contains';\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' && containsValidator(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): boolean => 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"]}
@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isAlphaValidator from 'validator/lib/isAlpha';
export var 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' && isAlphaValidator(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: function (value, args) { return isAlpha(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain only letters (a-zA-Z)'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsAlpha.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsAlpha.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsAlpha.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AAGrD,MAAM,CAAC,IAAM,QAAQ,GAAG,SAAS,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,MAAgC;IACtE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACtE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,MAAgC,EAAE,iBAAqC;IAC7F,OAAO,UAAU,CACf;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,OAAO,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAApC,CAAoC;YACxE,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,8CAA8C,EAA3D,CAA2D,EACzE,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isAlphaValidator from 'validator/lib/isAlpha';\nimport * as 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' && isAlphaValidator(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?: ValidatorJS.AlphaLocale, validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_ALPHA,\n constraints: [locale],\n validator: {\n validate: (value, args): boolean => 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"]}
@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isAlphanumericValidator from 'validator/lib/isAlphanumeric';
export var 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' && isAlphanumericValidator(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: function (value, args) { return isAlphanumeric(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain only letters and numbers'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsAlphanumeric.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsAlphanumeric.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsAlphanumeric.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AAGnE,MAAM,CAAC,IAAM,eAAe,GAAG,gBAAgB,CAAC;AAEhD;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,MAAuC;IACpF,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC7E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAuC,EACvC,iBAAqC;IAErC,OAAO,UAAU,CACf;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,CAAC,MAAM,CAAC;QACrB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,cAAc,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAA3C,CAA2C;YAC/E,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,iDAAiD,EAA9D,CAA8D,EAC5E,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isAlphanumericValidator from 'validator/lib/isAlphanumeric';\nimport * as 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' && isAlphanumericValidator(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(\n locale?: ValidatorJS.AlphanumericLocale,\n validationOptions?: ValidationOptions\n): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_ALPHANUMERIC,\n constraints: [locale],\n validator: {\n validate: (value, args): boolean => 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"]}
@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isAsciiValidator from 'validator/lib/isAscii';
export var 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' && isAsciiValidator(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: function (value, args) { return isAscii(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must contain only ASCII characters'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsAscii.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsAscii.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsAscii.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AAErD,MAAM,CAAC,IAAM,QAAQ,GAAG,SAAS,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,iBAAqC;IAC3D,OAAO,UAAU,CACf;QACE,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,OAAO,CAAC,KAAK,CAAC,EAAd,CAAc;YAClD,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,8CAA8C,EAA3D,CAA2D,EACzE,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isAsciiValidator from 'validator/lib/isAscii';\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' && isAsciiValidator(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): boolean => isAscii(value),\n defaultMessage: buildMessage(\n eachPrefix => eachPrefix + '$property must contain only ASCII characters',\n validationOptions\n ),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBICValidator from 'validator/lib/isBIC';
export var 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' && isBICValidator(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: function (value, args) { return isBIC(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a BIC or SWIFT code'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsBIC.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsBIC.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsBIC.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,MAAM,CAAC,IAAM,MAAM,GAAG,OAAO,CAAC;AAE9B;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,iBAAqC;IACzD,OAAO,UAAU,CACf;QACE,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,KAAK,CAAC,KAAK,CAAC,EAAZ,CAAY;YAChD,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,uCAAuC,EAApD,CAAoD,EAClE,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isBICValidator from 'validator/lib/isBIC';\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' && isBICValidator(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): boolean => 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"]}
@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBase32Validator from 'validator/lib/isBase32';
export var 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' && isBase32Validator(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: function (value, args) { return isBase32(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be base32 encoded'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsBase32.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsBase32.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsBase32.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAEvD,MAAM,CAAC,IAAM,SAAS,GAAG,UAAU,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,iBAAqC;IAC5D,OAAO,UAAU,CACf;QACE,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,QAAQ,CAAC,KAAK,CAAC,EAAf,CAAe;YACnD,cAAc,EAAE,YAAY,CAAC,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,kCAAkC,EAA/C,CAA+C,EAAE,iBAAiB,CAAC;SAC/G;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isBase32Validator from 'validator/lib/isBase32';\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' && isBase32Validator(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): boolean => isBase32(value),\n defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be base32 encoded', validationOptions),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBase58Validator from 'validator/lib/isBase58';
export var IS_BASE58 = 'isBase58';
/**
* Checks if a string is base58 encoded.
* If given value is not a string, then it returns false.
*/
export function isBase58(value) {
return typeof value === 'string' && isBase58Validator(value);
}
/**
* Checks if a string is base58 encoded.
* If given value is not a string, then it returns false.
*/
export function IsBase58(validationOptions) {
return ValidateBy({
name: IS_BASE58,
validator: {
validate: function (value, args) { return isBase58(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be base58 encoded'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsBase58.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsBase58.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsBase58.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAEvD,MAAM,CAAC,IAAM,SAAS,GAAG,UAAU,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,iBAAqC;IAC5D,OAAO,UAAU,CACf;QACE,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,QAAQ,CAAC,KAAK,CAAC,EAAf,CAAe;YACnD,cAAc,EAAE,YAAY,CAAC,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,kCAAkC,EAA/C,CAA+C,EAAE,iBAAiB,CAAC;SAC/G;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isBase58Validator from 'validator/lib/isBase58';\n\nexport const IS_BASE58 = 'isBase58';\n\n/**\n * Checks if a string is base58 encoded.\n * If given value is not a string, then it returns false.\n */\nexport function isBase58(value: unknown): boolean {\n return typeof value === 'string' && isBase58Validator(value);\n}\n\n/**\n * Checks if a string is base58 encoded.\n * If given value is not a string, then it returns false.\n */\nexport function IsBase58(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_BASE58,\n validator: {\n validate: (value, args): boolean => isBase58(value),\n defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be base58 encoded', validationOptions),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBase64Validator from 'validator/lib/isBase64';
export var 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, options) {
return typeof value === 'string' && isBase64Validator(value, options);
}
/**
* Checks if a string is base64 encoded.
* If given value is not a string, then it returns false.
*/
export function IsBase64(options, validationOptions) {
return ValidateBy({
name: IS_BASE64,
constraints: [options],
validator: {
validate: function (value, args) { return isBase64(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be base64 encoded'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsBase64.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsBase64.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsBase64.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAGvD,MAAM,CAAC,IAAM,SAAS,GAAG,UAAU,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc,EAAE,OAAqC;IAC5E,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CACtB,OAAqC,EACrC,iBAAqC;IAErC,OAAO,UAAU,CACf;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,CAAC,OAAO,CAAC;QACtB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,QAAQ,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAArC,CAAqC;YACzE,cAAc,EAAE,YAAY,CAAC,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,kCAAkC,EAA/C,CAA+C,EAAE,iBAAiB,CAAC;SAC/G;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isBase64Validator from 'validator/lib/isBase64';\nimport * as ValidatorJS 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, options?: ValidatorJS.IsBase64Options): boolean {\n return typeof value === 'string' && isBase64Validator(value, options);\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(\n options?: ValidatorJS.IsBase64Options,\n validationOptions?: ValidationOptions\n): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_BASE64,\n constraints: [options],\n validator: {\n validate: (value, args): boolean => isBase64(value, args?.constraints[0]),\n defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be base64 encoded', validationOptions),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBooleanValidator from 'validator/lib/isBoolean';
export var 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' && isBooleanValidator(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: function (value, args) { return isBooleanString(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a boolean string'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsBooleanString.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsBooleanString.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsBooleanString.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AAEzD,MAAM,CAAC,IAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,iBAAqC;IACnE,OAAO,UAAU,CACf;QACE,IAAI,EAAE,iBAAiB;QACvB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,eAAe,CAAC,KAAK,CAAC,EAAtB,CAAsB;YAC1D,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,oCAAoC,EAAjD,CAAiD,EAC/D,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isBooleanValidator from 'validator/lib/isBoolean';\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' && isBooleanValidator(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): boolean => isBooleanString(value),\n defaultMessage: buildMessage(\n eachPrefix => eachPrefix + '$property must be a boolean string',\n validationOptions\n ),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBtcAddressValidator from 'validator/lib/isBtcAddress';
export var 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' && isBtcAddressValidator(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: function (value, args) { return isBtcAddress(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a BTC address'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsBtcAddress.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsBtcAddress.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsBtcAddress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAE/D,MAAM,CAAC,IAAM,cAAc,GAAG,cAAc,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,iBAAqC;IAChE,OAAO,UAAU,CACf;QACE,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,YAAY,CAAC,KAAK,CAAC,EAAnB,CAAmB;YACvD,cAAc,EAAE,YAAY,CAAC,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,iCAAiC,EAA9C,CAA8C,EAAE,iBAAiB,CAAC;SAC9G;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isBtcAddressValidator from 'validator/lib/isBtcAddress';\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' && isBtcAddressValidator(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): boolean => isBtcAddress(value),\n defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be a BTC address', validationOptions),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isByteLengthValidator from 'validator/lib/isByteLength';
export var 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' && isByteLengthValidator(value, { min: min, max: 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: function (value, args) { return isByteLength(value, args === null || args === void 0 ? void 0 : args.constraints[0], args === null || args === void 0 ? void 0 : args.constraints[1]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + "$property's byte length must fall into ($constraint1, $constraint2) range"; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsByteLength.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsByteLength.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsByteLength.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAE/D,MAAM,CAAC,IAAM,cAAc,GAAG,cAAc,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,GAAW,EAAE,GAAY;IACpE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,qBAAqB,CAAC,KAAK,EAAE,EAAE,GAAG,KAAA,EAAE,GAAG,KAAA,EAAE,CAAC,CAAC;AACjF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,GAAY,EAAE,iBAAqC;IAC3F,OAAO,UAAU,CACf;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;QACvB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,YAAY,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAA/D,CAA+D;YACnG,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,2EAA2E,EAAxF,CAAwF,EACtG,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isByteLengthValidator from 'validator/lib/isByteLength';\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' && isByteLengthValidator(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): boolean => 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"]}
@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isCreditCardValidator from 'validator/lib/isCreditCard';
export var 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' && isCreditCardValidator(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: function (value, args) { return isCreditCard(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a credit card'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsCreditCard.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsCreditCard.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsCreditCard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAE/D,MAAM,CAAC,IAAM,cAAc,GAAG,cAAc,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,iBAAqC;IAChE,OAAO,UAAU,CACf;QACE,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,YAAY,CAAC,KAAK,CAAC,EAAnB,CAAmB;YACvD,cAAc,EAAE,YAAY,CAAC,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,iCAAiC,EAA9C,CAA8C,EAAE,iBAAiB,CAAC;SAC9G;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isCreditCardValidator from 'validator/lib/isCreditCard';\n\nexport const IS_CREDIT_CARD = 'isCreditCard';\n\n/**\n * Checks if the string is a credit card.\n * If given value is not a string, then it returns false.\n */\nexport function isCreditCard(value: unknown): boolean {\n return typeof value === 'string' && isCreditCardValidator(value);\n}\n\n/**\n * Checks if the string is a credit card.\n * If given value is not a string, then it returns false.\n */\nexport function IsCreditCard(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_CREDIT_CARD,\n validator: {\n validate: (value, args): boolean => isCreditCard(value),\n defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be a credit card', validationOptions),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isCurrencyValidator from 'validator/lib/isCurrency';
export var IS_CURRENCY = 'isCurrency';
/**
* Checks if the string is a valid currency amount.
* If given value is not a string, then it returns false.
*/
export function isCurrency(value, options) {
return typeof value === 'string' && isCurrencyValidator(value, options);
}
/**
* Checks if the string is a valid currency amount.
* If given value is not a string, then it returns false.
*/
export function IsCurrency(options, validationOptions) {
return ValidateBy({
name: IS_CURRENCY,
constraints: [options],
validator: {
validate: function (value, args) { return isCurrency(value, args === null || args === void 0 ? void 0 : args.constraints[0]); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a currency'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsCurrency.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsCurrency.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsCurrency.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAG3D,MAAM,CAAC,IAAM,WAAW,GAAG,YAAY,CAAC;AAExC;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc,EAAE,OAAuC;IAChF,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC1E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,OAAuC,EACvC,iBAAqC;IAErC,OAAO,UAAU,CACf;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,CAAC,OAAO,CAAC;QACtB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,UAAU,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAvC,CAAuC;YAC3E,cAAc,EAAE,YAAY,CAAC,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,8BAA8B,EAA3C,CAA2C,EAAE,iBAAiB,CAAC;SAC3G;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isCurrencyValidator from 'validator/lib/isCurrency';\nimport * as ValidatorJS from 'validator';\n\nexport const IS_CURRENCY = 'isCurrency';\n\n/**\n * Checks if the string is a valid currency amount.\n * If given value is not a string, then it returns false.\n */\nexport function isCurrency(value: unknown, options?: ValidatorJS.IsCurrencyOptions): boolean {\n return typeof value === 'string' && isCurrencyValidator(value, options);\n}\n\n/**\n * Checks if the string is a valid currency amount.\n * If given value is not a string, then it returns false.\n */\nexport function IsCurrency(\n options?: ValidatorJS.IsCurrencyOptions,\n validationOptions?: ValidationOptions\n): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_CURRENCY,\n constraints: [options],\n validator: {\n validate: (value, args): boolean => isCurrency(value, args?.constraints[0]),\n defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be a currency', validationOptions),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isDataURIValidator from 'validator/lib/isDataURI';
export var IS_DATA_URI = 'isDataURI';
/**
* Check if the string is a data uri format.
* If given value is not a string, then it returns false.
*/
export function isDataURI(value) {
return typeof value === 'string' && isDataURIValidator(value);
}
/**
* Check if the string is a data uri format.
* If given value is not a string, then it returns false.
*/
export function IsDataURI(validationOptions) {
return ValidateBy({
name: IS_DATA_URI,
validator: {
validate: function (value, args) { return isDataURI(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a data uri format'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsDataURI.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsDataURI.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsDataURI.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AAEzD,MAAM,CAAC,IAAM,WAAW,GAAG,WAAW,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,iBAAqC;IAC7D,OAAO,UAAU,CACf;QACE,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,EAAE,IAAI,IAAc,OAAA,SAAS,CAAC,KAAK,CAAC,EAAhB,CAAgB;YACpD,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,qCAAqC,EAAlD,CAAkD,EAChE,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isDataURIValidator from 'validator/lib/isDataURI';\n\nexport const IS_DATA_URI = 'isDataURI';\n\n/**\n * Check if the string is a data uri format.\n * If given value is not a string, then it returns false.\n */\nexport function isDataURI(value: unknown): boolean {\n return typeof value === 'string' && isDataURIValidator(value);\n}\n\n/**\n * Check if the string is a data uri format.\n * If given value is not a string, then it returns false.\n */\nexport function IsDataURI(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_DATA_URI,\n validator: {\n validate: (value, args): boolean => isDataURI(value),\n defaultMessage: buildMessage(\n eachPrefix => eachPrefix + '$property must be a data uri format',\n validationOptions\n ),\n },\n },\n validationOptions\n );\n}\n"]}
@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import { isISO8601 } from './IsISO8601';
export var IS_DATE_STRING = 'isDateString';
/**
* Alias for IsISO8601 validator
*/
export function isDateString(value, options) {
return isISO8601(value, options);
}
/**
* Alias for IsISO8601 validator
*/
export function IsDateString(options, validationOptions) {
return ValidateBy({
name: IS_DATE_STRING,
constraints: [options],
validator: {
validate: function (value) { return isDateString(value, options); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + '$property must be a valid ISO 8601 date string'; }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsDateString.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IsDateString.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsDateString.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,IAAM,cAAc,GAAG,cAAc,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,OAAsC;IACjF,OAAO,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAsC,EACtC,iBAAqC;IAErC,OAAO,UAAU,CACf;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,CAAC,OAAO,CAAC;QACtB,SAAS,EAAE;YACT,QAAQ,EAAE,UAAC,KAAK,IAAc,OAAA,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,EAA5B,CAA4B;YAC1D,cAAc,EAAE,YAAY,CAC1B,UAAA,UAAU,IAAI,OAAA,UAAU,GAAG,gDAAgD,EAA7D,CAA6D,EAC3E,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport * as ValidatorJS from 'validator';\nimport { isISO8601 } from './IsISO8601';\n\nexport const IS_DATE_STRING = 'isDateString';\n\n/**\n * Alias for IsISO8601 validator\n */\nexport function isDateString(value: unknown, options?: ValidatorJS.IsISO8601Options): boolean {\n return isISO8601(value, options);\n}\n\n/**\n * Alias for IsISO8601 validator\n */\nexport function IsDateString(\n options?: ValidatorJS.IsISO8601Options,\n validationOptions?: ValidationOptions\n): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_DATE_STRING,\n constraints: [options],\n validator: {\n validate: (value): boolean => isDateString(value, options),\n defaultMessage: buildMessage(\n eachPrefix => eachPrefix + '$property must be a valid ISO 8601 date string',\n validationOptions\n ),\n },\n },\n validationOptions\n );\n}\n"]}

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