feat: Reinitialize frontend with SvelteKit and TypeScript

- Delete old Vite+Svelte frontend
- Initialize new SvelteKit project with TypeScript
- Configure Tailwind CSS v4 + DaisyUI
- Implement JWT authentication with auto-refresh
- Create login page with form validation (Zod)
- Add protected route guards
- Update Docker configuration for single-stage build
- Add E2E tests with Playwright (6/11 passing)
- Fix Svelte 5 reactivity with $state() runes

Known issues:
- 5 E2E tests failing (timing/async issues)
- Token refresh implementation needs debugging
- Validation error display timing
This commit is contained in:
2026-02-17 16:19:59 -05:00
parent 54df6018f5
commit de2d83092e
28274 changed files with 3816354 additions and 90 deletions

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/container.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,MAAM,gBAAgB,GAAqE,IAAI,CAAC;IAAA;QACtF,cAAS,GAAsC,EAAE,CAAC;IAU5D,CAAC;IATC,GAAG,CAAI,SAAsC;QAC3C,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QAC5E,IAAI,CAAC,QAAQ,EAAE,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;CACF,CAAC,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,MAAM,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"]}

View File

@@ -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

View File

@@ -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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YAC9E,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,4CAA4C,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"]}

View File

@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export const 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: (value, args) => arrayMaxSize(value, args === null || args === void 0 ? void 0 : args.constraints[0]),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must contain no more than $constraint1 elements', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=ArrayMaxSize.js.map

View File

@@ -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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YAC7E,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,2DAA2D,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"]}

View File

@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export const 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: (value, args) => arrayMinSize(value, args === null || args === void 0 ? void 0 : args.constraints[0]),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must contain at least $constraint1 elements', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=ArrayMinSize.js.map

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YAC7E,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,uDAAuD,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YACjF,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,kDAAkD,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"]}

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export const ARRAY_NOT_EMPTY = 'arrayNotEmpty';
/**
* Checks if given array is not empty.
* If null or undefined is given then this function returns false.
*/
export function arrayNotEmpty(array) {
return Array.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: (value, args) => arrayNotEmpty(value),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property should not be empty', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=ArrayNotEmpty.js.map

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC;YACxD,cAAc,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,+BAA+B,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"]}

View File

@@ -0,0 +1,31 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
export const ARRAY_UNIQUE = 'arrayUnique';
/**
* Checks if all array's values are unique. Comparison for objects is reference-based.
* If null or undefined is given then this function returns false.
*/
export function arrayUnique(array, identifier) {
if (!Array.isArray(array))
return false;
if (identifier) {
array = array.map(o => (o != null ? identifier(o) : o));
}
const uniqueItems = array.filter((a, b, c) => c.indexOf(a) === b);
return array.length === uniqueItems.length;
}
/**
* Checks if all array's values are unique. Comparison for objects is reference-based.
* If null or undefined is given then this function returns false.
*/
export function ArrayUnique(identifierOrOptions, validationOptions) {
const identifier = typeof identifierOrOptions === 'function' ? identifierOrOptions : undefined;
const options = typeof identifierOrOptions !== 'function' ? identifierOrOptions : validationOptions;
return ValidateBy({
name: ARRAY_UNIQUE,
validator: {
validate: (value, args) => arrayUnique(value, identifier),
defaultMessage: buildMessage(eachPrefix => eachPrefix + "All $property's elements must be unique", options),
},
}, options);
}
//# sourceMappingURL=ArrayUnique.js.map

View File

@@ -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,MAAM,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,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,mBAAkE,EAClE,iBAAqC;IAErC,MAAM,UAAU,GAAG,OAAO,mBAAmB,KAAK,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/F,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC;YAClE,cAAc,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,yCAAyC,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"]}

View File

@@ -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) {
const args = {
type: ValidationTypes.WHITELIST,
target: object.constructor,
propertyName: propertyName,
validationOptions: validationOptions,
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=Allow.js.map

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YACvE,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,yCAAyC,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAW,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;YAC9C,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,2CAA2C,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;YAClD,cAAc,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,yBAAyB,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,aAAa,CAAC,EAAE,CAAC,aAAa,KAAK,KAAK,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YACrE,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,6DAA6D,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"]}

View File

@@ -0,0 +1,22 @@
import { buildMessage, ValidateBy } from './ValidateBy';
import isLatLongValidator from 'validator/lib/isLatLong';
export const 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: (value, args) => isLatLong(value),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be a latitude,longitude string', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsLatLong.js.map

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;YACpD,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,+CAA+C,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,GAAG,KAAK,IAAI,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;YACrD,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,+CAA+C,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,KAAK,KAAK,EAAE,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC;YACtD,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,gDAAgD,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;YACrD,cAAc,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,+BAA+B,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,aAAa,CAAC,EAAE,CAAC,aAAa,KAAK,KAAK,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YACxE,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,mEAAmE,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,WAAW,GAAG,YAAY,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,iBAAqC;IAC9D,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,MAAM,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,CAAC,MAAW,EAAE,KAAU,EAAW,EAAE;oBACnC,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YAC1E,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,+CAA+C,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"]}

View File

@@ -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) {
const isAsync = options && options.async;
let name = options && options.name ? options.name : '';
if (!name) {
name = target.name;
if (!name)
// generate name if it was not given
name = name.replace(/\.?([A-Z]+)/g, (x, y) => '_' + y.toLowerCase()).replace(/^_/, '');
}
const metadata = new ConstraintMetadata(target, name, isAsync);
getMetadataStorage().addConstraintMetadata(metadata);
};
}
export function Validate(constraintClass, constraintsOrValidationOptions, maybeValidationOptions) {
return function (object, propertyName) {
const args = {
type: ValidationTypes.CUSTOM_VALIDATION,
target: object.constructor,
propertyName: propertyName,
constraintCls: constraintClass,
constraints: Array.isArray(constraintsOrValidationOptions) ? constraintsOrValidationOptions : undefined,
validationOptions: !Array.isArray(constraintsOrValidationOptions)
? constraintsOrValidationOptions
: maybeValidationOptions,
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=Validate.js.map

View File

@@ -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,MAAM,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,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAI,CAAY,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACvG,CAAC;QACD,MAAM,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,MAAM,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,CAAC,mBAAyC,EAAU,EAAE;QAC3D,MAAM,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"]}

View File

@@ -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) {
const args = {
type: ValidationTypes.CONDITIONAL_VALIDATION,
target: object.constructor,
propertyName: propertyName,
constraints: [condition],
validationOptions: validationOptions,
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=ValidateIf.js.map

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,IAAI,GAAsB,EAAE,GAAG,iBAAiB,EAAE,CAAC;IACzD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,UAAU,GAAG,0DAA0D,CAAC;IAEvG,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,MAAM,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"]}

View File

@@ -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) {
const args = {
type: ValidationTypes.PROMISE_VALIDATION,
target: object.constructor,
propertyName: propertyName,
validationOptions: validationOptions,
};
getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
};
}
//# sourceMappingURL=ValidatePromise.js.map

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YACxE,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,2BAA2B,GAAG,UAAU,GAAG,2BAA2B,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YACxE,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,2BAA2B,GAAG,UAAU,GAAG,2BAA2B,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"]}

View File

@@ -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

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isDivisibleByValidator from 'validator/lib/isDivisibleBy';
export const IS_DIVISIBLE_BY = 'isDivisibleBy';
/**
* Checks if value is a number that's divisible by another.
*/
export function isDivisibleBy(value, num) {
return typeof value === 'number' && typeof num === 'number' && 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: (value, args) => isDivisibleBy(value, args === null || args === void 0 ? void 0 : args.constraints[0]),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be divisible by $constraint1', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsDivisibleBy.js.map

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YAC9E,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,6CAA6C,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;YACrD,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,qCAAqC,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;YACrD,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,qCAAqC,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YACpE,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,iDAAiD,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YACpE,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,8CAA8C,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YAC3E,cAAc,EAAE,YAAY,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE;gBAChD,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;oBACzB,OAAO,UAAU,GAAG,oCAAoC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,EAAE,IAAc,EAAE,CAAC;gBAChG,CAAC;qBAAM,CAAC;oBACN,OAAO,UAAU,GAAG,GAAG,WAAW,8DAA8D,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"]}

View File

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

View File

@@ -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,MAAM,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,aAAa,CAAC,EAAE,CAAC,aAAa,KAAK,IAAI,IAAI,aAAa,KAAK,SAAS,CAAC,CAAC;IAC7G,CAAC;IAED,KAAK,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YACjF,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,sCAAsC,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"]}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import containsValidator from 'validator/lib/contains';
export const CONTAINS = 'contains';
/**
* Checks if the string contains the seed.
* If given value is not a string, then it returns false.
*/
export function contains(value, seed) {
return typeof value === 'string' && 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: (value, args) => contains(value, args === null || args === void 0 ? void 0 : args.constraints[0]),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must contain a $constraint1 string', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=Contains.js.map

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YACzE,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,8CAA8C,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"]}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isAlphaValidator from 'validator/lib/isAlpha';
export const IS_ALPHA = 'isAlpha';
/**
* Checks if the string contains only letters (a-zA-Z).
* If given value is not a string, then it returns false.
*/
export function isAlpha(value, locale) {
return typeof value === 'string' && 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: (value, args) => isAlpha(value, args === null || args === void 0 ? void 0 : args.constraints[0]),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must contain only letters (a-zA-Z)', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsAlpha.js.map

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YACxE,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,8CAA8C,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"]}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isAlphanumericValidator from 'validator/lib/isAlphanumeric';
export const IS_ALPHANUMERIC = 'isAlphanumeric';
/**
* Checks if the string contains only letters and numbers.
* If given value is not a string, then it returns false.
*/
export function isAlphanumeric(value, locale) {
return typeof value === 'string' && 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: (value, args) => isAlphanumeric(value, args === null || args === void 0 ? void 0 : args.constraints[0]),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must contain only letters and numbers', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsAlphanumeric.js.map

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YAC/E,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,iDAAiD,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;YAClD,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,8CAA8C,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;YAChD,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,uCAAuC,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"]}

View File

@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBase32Validator from 'validator/lib/isBase32';
export const IS_BASE32 = 'isBase32';
/**
* Checks if a string is base32 encoded.
* If given value is not a string, then it returns false.
*/
export function isBase32(value) {
return typeof value === 'string' && 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: (value, args) => isBase32(value),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be base32 encoded', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsBase32.js.map

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;YACnD,cAAc,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,kCAAkC,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"]}

View File

@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBase58Validator from 'validator/lib/isBase58';
export const 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: (value, args) => isBase58(value),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be base58 encoded', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsBase58.js.map

View File

@@ -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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;YACnD,cAAc,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,kCAAkC,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"]}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBase64Validator from 'validator/lib/isBase64';
export const IS_BASE64 = 'isBase64';
/**
* Checks if a string is base64 encoded.
* If given value is not a string, then it returns false.
*/
export function isBase64(value, 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: (value, args) => isBase64(value, args === null || args === void 0 ? void 0 : args.constraints[0]),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be base64 encoded', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsBase64.js.map

View File

@@ -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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YACzE,cAAc,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,kCAAkC,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC;YAC1D,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,oCAAoC,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC;YACvD,cAAc,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,iCAAiC,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"]}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"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,MAAM,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,EAAE,GAAG,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,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;YACnG,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,2EAA2E,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"]}

View File

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

View File

@@ -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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC;YACvD,cAAc,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,iCAAiC,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"]}

View File

@@ -0,0 +1,25 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isCurrencyValidator from 'validator/lib/isCurrency';
export const 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: (value, args) => isCurrency(value, args === null || args === void 0 ? void 0 : args.constraints[0]),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be a currency', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsCurrency.js.map

View File

@@ -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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YAC3E,cAAc,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,8BAA8B,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"]}

View File

@@ -0,0 +1,24 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isDataURIValidator from 'validator/lib/isDataURI';
export const 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: (value, args) => isDataURI(value),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be a data uri format', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsDataURI.js.map

View File

@@ -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,MAAM,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,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;YACpD,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,qCAAqC,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"]}

View File

@@ -0,0 +1,23 @@
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import { isISO8601 } from './IsISO8601';
export const 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: (value) => isDateString(value, options),
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be a valid ISO 8601 date string', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsDateString.js.map

View File

@@ -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,MAAM,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,CAAC,KAAK,EAAW,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC;YAC1D,cAAc,EAAE,YAAY,CAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,gDAAgD,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