@decaf-ts/decorator-validation 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +302 -0
- package/dist/decorator-validation.bundle.min.js +2 -0
- package/dist/decorator-validation.bundle.min.js.LICENSE.txt +14 -0
- package/dist/esm/decorator-validation.bundle.min.esm.js +2 -0
- package/dist/esm/decorator-validation.bundle.min.esm.js.LICENSE.txt +14 -0
- package/lib/esm/index.d.ts +61 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/model/Model.d.ts +160 -0
- package/lib/esm/model/Model.js +1 -0
- package/lib/esm/model/ModelErrorDefinition.d.ts +22 -0
- package/lib/esm/model/ModelErrorDefinition.js +3 -0
- package/lib/esm/model/Registry.d.ts +61 -0
- package/lib/esm/model/Registry.js +1 -0
- package/lib/esm/model/constants.d.ts +40 -0
- package/lib/esm/model/constants.js +1 -0
- package/lib/esm/model/construction.d.ts +45 -0
- package/lib/esm/model/construction.js +1 -0
- package/lib/esm/model/decorators.d.ts +33 -0
- package/lib/esm/model/decorators.js +1 -0
- package/lib/esm/model/index.d.ts +7 -0
- package/lib/esm/model/index.js +1 -0
- package/lib/esm/model/types.d.ts +67 -0
- package/lib/esm/model/types.js +0 -0
- package/lib/esm/utils/constants.d.ts +22 -0
- package/lib/esm/utils/constants.js +1 -0
- package/lib/esm/utils/general.d.ts +193 -0
- package/lib/esm/utils/general.js +1 -0
- package/lib/esm/utils/index.d.ts +4 -0
- package/lib/esm/utils/index.js +1 -0
- package/lib/esm/utils/registry.d.ts +68 -0
- package/lib/esm/utils/registry.js +0 -0
- package/lib/esm/utils/serialization.d.ts +65 -0
- package/lib/esm/utils/serialization.js +1 -0
- package/lib/esm/validation/Validation.d.ts +39 -0
- package/lib/esm/validation/Validation.js +1 -0
- package/lib/esm/validation/Validators/DateValidator.d.ts +29 -0
- package/lib/esm/validation/Validators/DateValidator.js +1 -0
- package/lib/esm/validation/Validators/EmailValidator.d.ts +29 -0
- package/lib/esm/validation/Validators/EmailValidator.js +1 -0
- package/lib/esm/validation/Validators/ListValidator.d.ts +29 -0
- package/lib/esm/validation/Validators/ListValidator.js +1 -0
- package/lib/esm/validation/Validators/MaxLengthValidator.d.ts +30 -0
- package/lib/esm/validation/Validators/MaxLengthValidator.js +1 -0
- package/lib/esm/validation/Validators/MaxValidator.d.ts +29 -0
- package/lib/esm/validation/Validators/MaxValidator.js +1 -0
- package/lib/esm/validation/Validators/MinLengthValidator.d.ts +30 -0
- package/lib/esm/validation/Validators/MinLengthValidator.js +1 -0
- package/lib/esm/validation/Validators/MinValidator.d.ts +29 -0
- package/lib/esm/validation/Validators/MinValidator.js +1 -0
- package/lib/esm/validation/Validators/PasswordValidator.d.ts +31 -0
- package/lib/esm/validation/Validators/PasswordValidator.js +1 -0
- package/lib/esm/validation/Validators/PatternValidator.d.ts +38 -0
- package/lib/esm/validation/Validators/PatternValidator.js +1 -0
- package/lib/esm/validation/Validators/RequiredValidator.d.ts +28 -0
- package/lib/esm/validation/Validators/RequiredValidator.js +1 -0
- package/lib/esm/validation/Validators/StepValidator.d.ts +29 -0
- package/lib/esm/validation/Validators/StepValidator.js +1 -0
- package/lib/esm/validation/Validators/TypeValidator.d.ts +28 -0
- package/lib/esm/validation/Validators/TypeValidator.js +1 -0
- package/lib/esm/validation/Validators/URLValidator.d.ts +28 -0
- package/lib/esm/validation/Validators/URLValidator.js +1 -0
- package/lib/esm/validation/Validators/Validator.d.ts +42 -0
- package/lib/esm/validation/Validators/Validator.js +1 -0
- package/lib/esm/validation/Validators/ValidatorRegistry.d.ts +47 -0
- package/lib/esm/validation/Validators/ValidatorRegistry.js +1 -0
- package/lib/esm/validation/Validators/constants.d.ts +91 -0
- package/lib/esm/validation/Validators/constants.js +1 -0
- package/lib/esm/validation/Validators/index.d.ts +50 -0
- package/lib/esm/validation/Validators/index.js +1 -0
- package/lib/esm/validation/Validators/types.d.ts +51 -0
- package/lib/esm/validation/Validators/types.js +0 -0
- package/lib/esm/validation/decorators.d.ts +263 -0
- package/lib/esm/validation/decorators.js +1 -0
- package/lib/esm/validation/index.d.ts +13 -0
- package/lib/esm/validation/index.js +1 -0
- package/lib/esm/validation/types.d.ts +53 -0
- package/lib/esm/validation/types.js +0 -0
- package/lib/index.cjs +1 -0
- package/lib/index.d.ts +61 -0
- package/lib/model/Model.cjs +1 -0
- package/lib/model/Model.d.ts +160 -0
- package/lib/model/ModelErrorDefinition.cjs +3 -0
- package/lib/model/ModelErrorDefinition.d.ts +22 -0
- package/lib/model/Registry.cjs +1 -0
- package/lib/model/Registry.d.ts +61 -0
- package/lib/model/constants.cjs +1 -0
- package/lib/model/constants.d.ts +40 -0
- package/lib/model/construction.cjs +1 -0
- package/lib/model/construction.d.ts +45 -0
- package/lib/model/decorators.cjs +1 -0
- package/lib/model/decorators.d.ts +33 -0
- package/lib/model/index.cjs +1 -0
- package/lib/model/index.d.ts +7 -0
- package/lib/model/types.cjs +1 -0
- package/lib/model/types.d.ts +67 -0
- package/lib/utils/constants.cjs +1 -0
- package/lib/utils/constants.d.ts +22 -0
- package/lib/utils/general.cjs +1 -0
- package/lib/utils/general.d.ts +193 -0
- package/lib/utils/index.cjs +1 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/registry.cjs +1 -0
- package/lib/utils/registry.d.ts +68 -0
- package/lib/utils/serialization.cjs +1 -0
- package/lib/utils/serialization.d.ts +65 -0
- package/lib/validation/Validation.cjs +1 -0
- package/lib/validation/Validation.d.ts +39 -0
- package/lib/validation/Validators/DateValidator.cjs +1 -0
- package/lib/validation/Validators/DateValidator.d.ts +29 -0
- package/lib/validation/Validators/EmailValidator.cjs +1 -0
- package/lib/validation/Validators/EmailValidator.d.ts +29 -0
- package/lib/validation/Validators/ListValidator.cjs +1 -0
- package/lib/validation/Validators/ListValidator.d.ts +29 -0
- package/lib/validation/Validators/MaxLengthValidator.cjs +1 -0
- package/lib/validation/Validators/MaxLengthValidator.d.ts +30 -0
- package/lib/validation/Validators/MaxValidator.cjs +1 -0
- package/lib/validation/Validators/MaxValidator.d.ts +29 -0
- package/lib/validation/Validators/MinLengthValidator.cjs +1 -0
- package/lib/validation/Validators/MinLengthValidator.d.ts +30 -0
- package/lib/validation/Validators/MinValidator.cjs +1 -0
- package/lib/validation/Validators/MinValidator.d.ts +29 -0
- package/lib/validation/Validators/PasswordValidator.cjs +1 -0
- package/lib/validation/Validators/PasswordValidator.d.ts +31 -0
- package/lib/validation/Validators/PatternValidator.cjs +1 -0
- package/lib/validation/Validators/PatternValidator.d.ts +38 -0
- package/lib/validation/Validators/RequiredValidator.cjs +1 -0
- package/lib/validation/Validators/RequiredValidator.d.ts +28 -0
- package/lib/validation/Validators/StepValidator.cjs +1 -0
- package/lib/validation/Validators/StepValidator.d.ts +29 -0
- package/lib/validation/Validators/TypeValidator.cjs +1 -0
- package/lib/validation/Validators/TypeValidator.d.ts +28 -0
- package/lib/validation/Validators/URLValidator.cjs +1 -0
- package/lib/validation/Validators/URLValidator.d.ts +28 -0
- package/lib/validation/Validators/Validator.cjs +1 -0
- package/lib/validation/Validators/Validator.d.ts +42 -0
- package/lib/validation/Validators/ValidatorRegistry.cjs +1 -0
- package/lib/validation/Validators/ValidatorRegistry.d.ts +47 -0
- package/lib/validation/Validators/constants.cjs +1 -0
- package/lib/validation/Validators/constants.d.ts +91 -0
- package/lib/validation/Validators/index.cjs +1 -0
- package/lib/validation/Validators/index.d.ts +50 -0
- package/lib/validation/Validators/types.cjs +1 -0
- package/lib/validation/Validators/types.d.ts +51 -0
- package/lib/validation/decorators.cjs +1 -0
- package/lib/validation/decorators.d.ts +263 -0
- package/lib/validation/index.cjs +1 -0
- package/lib/validation/index.d.ts +13 -0
- package/lib/validation/types.cjs +1 -0
- package/lib/validation/types.d.ts +53 -0
- package/package.json +96 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Validation=void 0;const Validators_1=require("./Validators/index.cjs"),utils_1=require("../utils/index.cjs");class Validation{static{this.actingValidatorRegistry=void 0}constructor(){}static setRegistry(i,a){a&&Validation.actingValidatorRegistry&&Validation.actingValidatorRegistry.getKeys().forEach(t=>{t=i.get(t);t&&i.register(a(t))}),Validation.actingValidatorRegistry=i}static getRegistry(){return Validation.actingValidatorRegistry||(Validation.actingValidatorRegistry=new Validators_1.ValidatorRegistry({validator:Validators_1.TypeValidator,validationKey:utils_1.ModelKeys.TYPE,save:!1})),Validation.actingValidatorRegistry}static get(t){return Validation.getRegistry().get(t)}static register(...t){return Validation.getRegistry().register(...t)}}exports.Validation=Validation;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IValidatorRegistry, Validator, ValidatorDefinition } from "./Validators";
|
|
2
|
+
/**
|
|
3
|
+
* @summary Static class acting as a namespace for the Validation
|
|
4
|
+
*
|
|
5
|
+
* @class Validation
|
|
6
|
+
* @static
|
|
7
|
+
*
|
|
8
|
+
* @category Validation
|
|
9
|
+
*/
|
|
10
|
+
export declare class Validation {
|
|
11
|
+
private static actingValidatorRegistry?;
|
|
12
|
+
private constructor();
|
|
13
|
+
/**
|
|
14
|
+
* @summary Defines the acting ValidatorRegistry
|
|
15
|
+
*
|
|
16
|
+
* @param {IValidatorRegistry} validatorRegistry the new implementation of the validator Registry
|
|
17
|
+
* @param {function(Validator): Validator} [migrationHandler] the method to map the validator if required;
|
|
18
|
+
*/
|
|
19
|
+
static setRegistry(validatorRegistry: IValidatorRegistry<Validator>, migrationHandler?: (validator: Validator) => Validator): void;
|
|
20
|
+
/**
|
|
21
|
+
* @summary Returns the current ValidatorRegistry
|
|
22
|
+
*
|
|
23
|
+
* @return IValidatorRegistry, defaults to {@link ValidatorRegistry}
|
|
24
|
+
*/
|
|
25
|
+
private static getRegistry;
|
|
26
|
+
/**
|
|
27
|
+
* @summary Retrieves a validator
|
|
28
|
+
*
|
|
29
|
+
* @param {string} validatorKey one of the {@link ValidationKeys}
|
|
30
|
+
* @return {Validator | undefined} the registered Validator or undefined if there is nono matching the provided key
|
|
31
|
+
*/
|
|
32
|
+
static get<T extends Validator>(validatorKey: string): T | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* @summary Registers the provided validators onto the registry
|
|
35
|
+
*
|
|
36
|
+
* @param {T[] | ValidatorDefinition[]} validator
|
|
37
|
+
*/
|
|
38
|
+
static register<T extends Validator>(...validator: (ValidatorDefinition | T)[]): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DateValidator=void 0;const Validator_1=require("./Validator/index.cjs"),constants_1=require("./constants/index.cjs");class DateValidator extends Validator_1.Validator{constructor(t=constants_1.DEFAULT_ERROR_MESSAGES.DATE){super(constants_1.ValidationKeys.DATE,t,Number.name,Date.name,String.name)}hasErrors(t,e,a){if(void 0!==t)return"string"==typeof t&&(t=new Date(t)),isNaN(t.getDate())?this.getMessage(a||this.message):void 0}}exports.DateValidator=DateValidator;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Validator } from "./Validator";
|
|
2
|
+
import { Errors } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* @summary Date Validator
|
|
5
|
+
*
|
|
6
|
+
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#DATE}
|
|
7
|
+
*
|
|
8
|
+
* @class DateValidator
|
|
9
|
+
* @extends Validator
|
|
10
|
+
*
|
|
11
|
+
* @category Validators
|
|
12
|
+
*/
|
|
13
|
+
export declare class DateValidator extends Validator {
|
|
14
|
+
constructor(message?: string);
|
|
15
|
+
/**
|
|
16
|
+
* @summary Validates a model
|
|
17
|
+
*
|
|
18
|
+
* @param {Date | string} value
|
|
19
|
+
* @param {string} format
|
|
20
|
+
* @param {string} [message]
|
|
21
|
+
*
|
|
22
|
+
* @return Errors
|
|
23
|
+
*
|
|
24
|
+
* @override
|
|
25
|
+
*
|
|
26
|
+
* @see Validator#hasErrors
|
|
27
|
+
*/
|
|
28
|
+
hasErrors(value: Date | string, format: string, message?: string): Errors;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EmailValidator=void 0;const constants_1=require("./constants/index.cjs"),PatternValidator_1=require("./PatternValidator/index.cjs");class EmailValidator extends PatternValidator_1.PatternValidator{static{this.emailPat=/[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/}constructor(a=constants_1.DEFAULT_ERROR_MESSAGES.EMAIL){super(constants_1.ValidationKeys.EMAIL,a)}hasErrors(a,t){return super.hasErrors(a,EmailValidator.emailPat,t)}}exports.EmailValidator=EmailValidator;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Errors } from "../types";
|
|
2
|
+
import { PatternValidator } from "./PatternValidator";
|
|
3
|
+
/**
|
|
4
|
+
* @summary Email Validator
|
|
5
|
+
*
|
|
6
|
+
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#EMAIL}
|
|
7
|
+
*
|
|
8
|
+
* @class EmailValidator
|
|
9
|
+
* @extends PatternValidator
|
|
10
|
+
*
|
|
11
|
+
* @category Validators
|
|
12
|
+
*/
|
|
13
|
+
export declare class EmailValidator extends PatternValidator {
|
|
14
|
+
private static readonly emailPat;
|
|
15
|
+
constructor(message?: string);
|
|
16
|
+
/**
|
|
17
|
+
* @summary Validates a model
|
|
18
|
+
*
|
|
19
|
+
* @param {string} value
|
|
20
|
+
* @param {string} [message]
|
|
21
|
+
*
|
|
22
|
+
* @return Errors
|
|
23
|
+
*
|
|
24
|
+
* @override
|
|
25
|
+
*
|
|
26
|
+
* @see Validator#hasErrors
|
|
27
|
+
*/
|
|
28
|
+
hasErrors(value: string, message?: string): Errors;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ListValidator=void 0;const Validator_1=require("./Validator/index.cjs"),constants_1=require("./constants/index.cjs");class ListValidator extends Validator_1.Validator{constructor(t=constants_1.DEFAULT_ERROR_MESSAGES.LIST){super(constants_1.ValidationKeys.LIST,t,Array.name,Set.name)}hasErrors(s,e,r){var a;if(s&&(Array.isArray(s)?s.length:s.size))for(let t=0;t<(Array.isArray(s)?s.length:s.size);t++)switch(typeof(a=s[t])){case"object":case"function":if(a.constructor&&a.constructor.name===e)break;return this.getMessage(r||this.message,e);default:if(typeof a!==e)return this.getMessage(r||this.message,e)}}}exports.ListValidator=ListValidator;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Validator } from "./Validator";
|
|
2
|
+
import { Errors } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* @summary List Validator
|
|
5
|
+
*
|
|
6
|
+
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#LIST}
|
|
7
|
+
*
|
|
8
|
+
* @class ListValidator
|
|
9
|
+
* @extends Validator
|
|
10
|
+
*
|
|
11
|
+
* @category Validators
|
|
12
|
+
*/
|
|
13
|
+
export declare class ListValidator extends Validator {
|
|
14
|
+
constructor(message?: string);
|
|
15
|
+
/**
|
|
16
|
+
* @summary Validates a model
|
|
17
|
+
*
|
|
18
|
+
* @param {any[] | Set<any>} value
|
|
19
|
+
* @param {string} clazz
|
|
20
|
+
* @param {string} [message]
|
|
21
|
+
*
|
|
22
|
+
* @return Errors
|
|
23
|
+
*
|
|
24
|
+
* @override
|
|
25
|
+
*
|
|
26
|
+
* @see Validator#hasErrors
|
|
27
|
+
*/
|
|
28
|
+
hasErrors(value: any[] | Set<any>, clazz: string, message?: string): Errors;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MaxLengthValidator=void 0;const Validator_1=require("./Validator/index.cjs"),constants_1=require("./constants/index.cjs");class MaxLengthValidator extends Validator_1.Validator{constructor(t=constants_1.DEFAULT_ERROR_MESSAGES.MAX_LENGTH){super(constants_1.ValidationKeys.MAX_LENGTH,t,String.name,Array.name)}hasErrors(t,a,e){return void 0!==t&&t.length>a?this.getMessage(e||this.message,a):void 0}}exports.MaxLengthValidator=MaxLengthValidator;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Errors } from "../types";
|
|
2
|
+
import { Validator } from "./Validator";
|
|
3
|
+
/**
|
|
4
|
+
* @summary Maximum Length Validator
|
|
5
|
+
* @description Validates strings and Arrays on their maximum length
|
|
6
|
+
*
|
|
7
|
+
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MAX_LENGTH}
|
|
8
|
+
*
|
|
9
|
+
* @class MinLengthValidator
|
|
10
|
+
* @extends Validator
|
|
11
|
+
*
|
|
12
|
+
* @category Validators
|
|
13
|
+
*/
|
|
14
|
+
export declare class MaxLengthValidator extends Validator {
|
|
15
|
+
constructor(message?: string);
|
|
16
|
+
/**
|
|
17
|
+
* @summary Validates a model
|
|
18
|
+
*
|
|
19
|
+
* @param {string} value
|
|
20
|
+
* @param {number} maxlength
|
|
21
|
+
* @param {string} [message]
|
|
22
|
+
*
|
|
23
|
+
* @return Errors
|
|
24
|
+
*
|
|
25
|
+
* @override
|
|
26
|
+
*
|
|
27
|
+
* @see Validator#hasErrors
|
|
28
|
+
*/
|
|
29
|
+
hasErrors(value: string | any[], maxlength: number, message?: string): Errors;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MaxValidator=void 0;const Validator_1=require("./Validator/index.cjs"),constants_1=require("./constants/index.cjs");class MaxValidator extends Validator_1.Validator{constructor(a=constants_1.DEFAULT_ERROR_MESSAGES.MAX){super(constants_1.ValidationKeys.MAX,a,"number","Date","string")}hasErrors(a,t,e){if(void 0!==a){if(a instanceof Date&&!(t instanceof Date)&&(t=new Date(t),isNaN(t.getDate())))throw new Error("Invalid Max param defined");return t<a?this.getMessage(e||this.message,t):void 0}}}exports.MaxValidator=MaxValidator;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Validator } from "./Validator";
|
|
2
|
+
import { Errors } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* @summary Max Validator
|
|
5
|
+
*
|
|
6
|
+
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MAX}
|
|
7
|
+
*
|
|
8
|
+
* @class MaxValidator
|
|
9
|
+
* @extends Validator
|
|
10
|
+
*
|
|
11
|
+
* @category Validators
|
|
12
|
+
*/
|
|
13
|
+
export declare class MaxValidator extends Validator {
|
|
14
|
+
constructor(message?: string);
|
|
15
|
+
/**
|
|
16
|
+
* @summary Validates a Model
|
|
17
|
+
*
|
|
18
|
+
* @param {string} value
|
|
19
|
+
* @param {number | Date | string} max
|
|
20
|
+
* @param {string} [message]
|
|
21
|
+
*
|
|
22
|
+
* @return Errors
|
|
23
|
+
*
|
|
24
|
+
* @override
|
|
25
|
+
*
|
|
26
|
+
* @see Validator#hasErrors
|
|
27
|
+
*/
|
|
28
|
+
hasErrors(value: number | Date | string, max: number | Date | string, message?: string): Errors;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MinLengthValidator=void 0;const Validator_1=require("./Validator/index.cjs"),constants_1=require("./constants/index.cjs");class MinLengthValidator extends Validator_1.Validator{constructor(t=constants_1.DEFAULT_ERROR_MESSAGES.MIN_LENGTH){super(constants_1.ValidationKeys.MIN_LENGTH,t,String.name,Array.name)}hasErrors(t,e,a){return void 0!==t&&t.length<e?this.getMessage(a||this.message,e):void 0}}exports.MinLengthValidator=MinLengthValidator;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Validator } from "./Validator";
|
|
2
|
+
import { Errors } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* @summary Minimum Length Validator
|
|
5
|
+
* @description Validates strings and Arrays on their minimum length
|
|
6
|
+
*
|
|
7
|
+
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MIN_LENGTH}
|
|
8
|
+
*
|
|
9
|
+
* @class MinLengthValidator
|
|
10
|
+
* @extends Validator
|
|
11
|
+
*
|
|
12
|
+
* @category Validators
|
|
13
|
+
*/
|
|
14
|
+
export declare class MinLengthValidator extends Validator {
|
|
15
|
+
constructor(message?: string);
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {string | Array} value
|
|
19
|
+
* @param {number} minlength
|
|
20
|
+
* @param {string} [message]
|
|
21
|
+
*
|
|
22
|
+
* @return Errors
|
|
23
|
+
*
|
|
24
|
+
* @memberOf MinLengthValidator
|
|
25
|
+
* @override
|
|
26
|
+
*
|
|
27
|
+
* @see Validator#hasErrors
|
|
28
|
+
*/
|
|
29
|
+
hasErrors(value: string | any[], minlength: number, message?: string): Errors;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MinValidator=void 0;const Validator_1=require("./Validator/index.cjs"),constants_1=require("./constants/index.cjs");class MinValidator extends Validator_1.Validator{constructor(t=constants_1.DEFAULT_ERROR_MESSAGES.MIN){super(constants_1.ValidationKeys.MIN,t,"number","Date","string")}hasErrors(t,a,e){if(void 0!==t){if(t instanceof Date&&!(a instanceof Date)&&(a=new Date(a),isNaN(a.getDate())))throw new Error("Invalid Min param defined");return t<a?this.getMessage(e||this.message,a):void 0}}}exports.MinValidator=MinValidator;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Validator } from "./Validator";
|
|
2
|
+
import { Errors } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* @summary Min Validator
|
|
5
|
+
*
|
|
6
|
+
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#MIN}
|
|
7
|
+
*
|
|
8
|
+
* @class MinValidator
|
|
9
|
+
* @extends Validator
|
|
10
|
+
*
|
|
11
|
+
* @category Validators
|
|
12
|
+
*/
|
|
13
|
+
export declare class MinValidator extends Validator {
|
|
14
|
+
constructor(message?: string);
|
|
15
|
+
/**
|
|
16
|
+
* @summary Validates Model
|
|
17
|
+
*
|
|
18
|
+
* @param {string} value
|
|
19
|
+
* @param {number | Date | string} min
|
|
20
|
+
* @param {string} [message]
|
|
21
|
+
*
|
|
22
|
+
* @return Errors
|
|
23
|
+
*
|
|
24
|
+
* @override
|
|
25
|
+
*
|
|
26
|
+
* @see Validator#hasErrors
|
|
27
|
+
*/
|
|
28
|
+
hasErrors(value: number | Date | string, min: number | Date | string, message?: string): Errors;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PasswordValidator=void 0;const PatternValidator_1=require("./PatternValidator/index.cjs"),constants_1=require("./constants/index.cjs");class PasswordValidator extends PatternValidator_1.PatternValidator{constructor(t=constants_1.DEFAULT_ERROR_MESSAGES.PASSWORD,s=constants_1.PasswordPatterns.CHAR8_ONE_OF_EACH){super(constants_1.ValidationKeys.PASSWORD,t),this.pattern=s}hasErrors(t,s,r){return super.hasErrors(t,s||this.pattern,r||this.message)}}exports.PasswordValidator=PasswordValidator;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PatternValidator } from "./PatternValidator";
|
|
2
|
+
import { Errors } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* @summary Handles Password Validation
|
|
5
|
+
*
|
|
6
|
+
* @param {string} [errorMessage] defaults to {@link DEFAULT_ERROR_MESSAGES#PASSWORD}
|
|
7
|
+
* @param {RegExp} [passwordPattern] defaults to {@link PasswordPatterns.CHAR8_ONE_OF_EACH}
|
|
8
|
+
*
|
|
9
|
+
* @class PasswordValidator
|
|
10
|
+
* @extends PatternValidator
|
|
11
|
+
*
|
|
12
|
+
* @category Validators
|
|
13
|
+
*/
|
|
14
|
+
export declare class PasswordValidator extends PatternValidator {
|
|
15
|
+
readonly pattern: RegExp;
|
|
16
|
+
constructor(errorMessage?: string, passwordPattern?: RegExp);
|
|
17
|
+
/**
|
|
18
|
+
* @summary Validates a model
|
|
19
|
+
*
|
|
20
|
+
* @param {string} value
|
|
21
|
+
* @param {RegExp} [pattern]
|
|
22
|
+
* @param {string} [message]
|
|
23
|
+
*
|
|
24
|
+
* @return Errors
|
|
25
|
+
*
|
|
26
|
+
* @override
|
|
27
|
+
*
|
|
28
|
+
* @see PatternValidator#hasErrors
|
|
29
|
+
*/
|
|
30
|
+
hasErrors(value: string, pattern: RegExp, message?: string): Errors;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PatternValidator=void 0;const Validator_1=require("./Validator/index.cjs"),constants_1=require("./constants/index.cjs");class PatternValidator extends Validator_1.Validator{static{this.regexpParser=new RegExp("^/(.+)/([gimus]*)$")}constructor(t=constants_1.ValidationKeys.PATTERN,e=constants_1.DEFAULT_ERROR_MESSAGES.PATTERN){super(t,e,"string")}static getPattern(t){var e;return PatternValidator.regexpParser.test(t)?(e=t.match(PatternValidator.regexpParser),new RegExp(e[1],e[2])):new RegExp(t)}hasErrors(t,e,r){if(t)return(e="string"==typeof e?PatternValidator.getPattern(e):e).lastIndex=0,e.test(t)?void 0:this.getMessage(r||this.message)}}exports.PatternValidator=PatternValidator;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Validator } from "./Validator";
|
|
2
|
+
import { Errors } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* @summary Pattern Validator
|
|
5
|
+
*
|
|
6
|
+
* @param {string} [key] defaults to {@link ValidationKeys#PATTERN}
|
|
7
|
+
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#PATTERN}
|
|
8
|
+
*
|
|
9
|
+
* @class PatternValidator
|
|
10
|
+
* @extends Validator
|
|
11
|
+
*
|
|
12
|
+
* @category Validators
|
|
13
|
+
*/
|
|
14
|
+
export declare class PatternValidator extends Validator {
|
|
15
|
+
private static readonly regexpParser;
|
|
16
|
+
constructor(key?: string, message?: string);
|
|
17
|
+
/**
|
|
18
|
+
* @summary parses and validates a pattern
|
|
19
|
+
*
|
|
20
|
+
* @param {string} pattern
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
private static getPattern;
|
|
24
|
+
/**
|
|
25
|
+
* @summary Validates a Model
|
|
26
|
+
*
|
|
27
|
+
* @param {string} value
|
|
28
|
+
* @param {RegExp | string} pattern
|
|
29
|
+
* @param {string} [message]
|
|
30
|
+
*
|
|
31
|
+
* @return Errors
|
|
32
|
+
*
|
|
33
|
+
* @override
|
|
34
|
+
*
|
|
35
|
+
* @see Validator#hasErrors
|
|
36
|
+
*/
|
|
37
|
+
hasErrors(value: string, pattern: RegExp | string, message?: string): Errors;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RequiredValidator=void 0;const Validator_1=require("./Validator/index.cjs"),constants_1=require("./constants/index.cjs");class RequiredValidator extends Validator_1.Validator{constructor(e=constants_1.DEFAULT_ERROR_MESSAGES.REQUIRED){super(constants_1.ValidationKeys.REQUIRED,e)}hasErrors(e,t){switch(typeof e){case"boolean":case"number":return void 0===e?this.getMessage(t||this.message):void 0;default:return e?void 0:this.getMessage(t||this.message)}}}exports.RequiredValidator=RequiredValidator;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Validator } from "./Validator";
|
|
2
|
+
import { Errors } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* @summary Required Validator
|
|
5
|
+
*
|
|
6
|
+
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#REQUIRED}
|
|
7
|
+
*
|
|
8
|
+
* @class RequiredValidator
|
|
9
|
+
* @extends Validator
|
|
10
|
+
*
|
|
11
|
+
* @category Validators
|
|
12
|
+
*/
|
|
13
|
+
export declare class RequiredValidator extends Validator {
|
|
14
|
+
constructor(message?: string);
|
|
15
|
+
/**
|
|
16
|
+
* @summary Validates a model
|
|
17
|
+
*
|
|
18
|
+
* @param {string} value
|
|
19
|
+
* @param {string} [message]
|
|
20
|
+
*
|
|
21
|
+
* @return Errors
|
|
22
|
+
*
|
|
23
|
+
* @override
|
|
24
|
+
*
|
|
25
|
+
* @see Validator#hasErrors
|
|
26
|
+
*/
|
|
27
|
+
hasErrors(value: any, message?: string): Errors;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StepValidator=void 0;const Validator_1=require("./Validator/index.cjs"),constants_1=require("./constants/index.cjs");class StepValidator extends Validator_1.Validator{constructor(t=constants_1.DEFAULT_ERROR_MESSAGES.STEP){super(constants_1.ValidationKeys.STEP,t,"number","string")}hasErrors(t,e,r){return void 0!==t&&Number(t)%Number(e)!=0?this.getMessage(r||this.message,e):void 0}}exports.StepValidator=StepValidator;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Validator } from "./Validator";
|
|
2
|
+
import { Errors } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* @summary Step Validator
|
|
5
|
+
*
|
|
6
|
+
* @param {string} [message] defaults to {@link DEFAULT_ERROR_MESSAGES#STEP}
|
|
7
|
+
*
|
|
8
|
+
* @class StepValidator
|
|
9
|
+
* @extends Validator
|
|
10
|
+
*
|
|
11
|
+
* @category Validators
|
|
12
|
+
*/
|
|
13
|
+
export declare class StepValidator extends Validator {
|
|
14
|
+
constructor(message?: string);
|
|
15
|
+
/**
|
|
16
|
+
* @summary Validates a model
|
|
17
|
+
*
|
|
18
|
+
* @param {string} value
|
|
19
|
+
* @param {number} step
|
|
20
|
+
* @param {string} [message]
|
|
21
|
+
*
|
|
22
|
+
* @return Errors
|
|
23
|
+
*
|
|
24
|
+
* @override
|
|
25
|
+
*
|
|
26
|
+
* @see Validator#hasErrors
|
|
27
|
+
*/
|
|
28
|
+
hasErrors(value: number | string, step: number | string, message?: string): Errors;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TypeValidator=void 0;const Validator_1=require("./Validator/index.cjs"),utils_1=require("../../utils/index.cjs"),constants_1=require("./constants/index.cjs"),constants_2=require("../../utils/constants/index.cjs");class TypeValidator extends Validator_1.Validator{constructor(t=constants_1.DEFAULT_ERROR_MESSAGES.TYPE){super(constants_2.ModelKeys.TYPE,t)}hasErrors(t,e,s){return void 0===t||(0,utils_1.evaluateDesignTypes)(t,e)?void 0:this.getMessage(s||this.message,"string"==typeof e?e:Array.isArray(e)?e.join(", "):e.name,typeof t)}}exports.TypeValidator=TypeValidator;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Errors } from "../types";
|
|
2
|
+
import { Validator } from "./Validator";
|
|
3
|
+
/**
|
|
4
|
+
* @summary Required Validator
|
|
5
|
+
*
|
|
6
|
+
* @class RequiredValidator
|
|
7
|
+
* @extends Validator
|
|
8
|
+
*
|
|
9
|
+
* @category Validators
|
|
10
|
+
*/
|
|
11
|
+
export declare class TypeValidator extends Validator {
|
|
12
|
+
constructor(message?: string);
|
|
13
|
+
/**
|
|
14
|
+
* @summary Validates a model
|
|
15
|
+
* @param {string} value
|
|
16
|
+
* @param {string | string[] | {name: string}} types
|
|
17
|
+
* @param {string} [message]
|
|
18
|
+
*
|
|
19
|
+
* @return Errors
|
|
20
|
+
*
|
|
21
|
+
* @override
|
|
22
|
+
*
|
|
23
|
+
* @see Validator#hasErrors
|
|
24
|
+
*/
|
|
25
|
+
hasErrors(value: any, types: string | string[] | {
|
|
26
|
+
name: string;
|
|
27
|
+
}, message?: string): Errors;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.URLValidator=void 0;const constants_1=require("./constants/index.cjs"),PatternValidator_1=require("./PatternValidator/index.cjs");class URLValidator extends PatternValidator_1.PatternValidator{static{this.urlPattern=/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i}constructor(t=constants_1.DEFAULT_ERROR_MESSAGES.URL){super(constants_1.ValidationKeys.URL,t)}hasErrors(t,a){return super.hasErrors(t,URLValidator.urlPattern,a)}}exports.URLValidator=URLValidator;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Errors } from "../types";
|
|
2
|
+
import { PatternValidator } from "./PatternValidator";
|
|
3
|
+
/**
|
|
4
|
+
* @summary URL Validator
|
|
5
|
+
* @description Pattern from {@link https://gist.github.com/dperini/729294}
|
|
6
|
+
*
|
|
7
|
+
* @class URLValidator
|
|
8
|
+
* @extends PatternValidator
|
|
9
|
+
*
|
|
10
|
+
* @category Validators
|
|
11
|
+
*/
|
|
12
|
+
export declare class URLValidator extends PatternValidator {
|
|
13
|
+
private static readonly urlPattern;
|
|
14
|
+
constructor(message?: string);
|
|
15
|
+
/**
|
|
16
|
+
* @summary Validates a model
|
|
17
|
+
*
|
|
18
|
+
* @param {string} value
|
|
19
|
+
* @param {string} [message]
|
|
20
|
+
*
|
|
21
|
+
* @return Errors
|
|
22
|
+
*
|
|
23
|
+
* @override
|
|
24
|
+
*
|
|
25
|
+
* @see Validator#hasErrors
|
|
26
|
+
*/
|
|
27
|
+
hasErrors(value: string, message?: string): Errors;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Validator=void 0;const utils_1=require("../../utils/index.cjs"),constants_1=require("./constants/index.cjs");class Validator{constructor(s,t=constants_1.DEFAULT_ERROR_MESSAGES.DEFAULT,...e){this.validationKey=s,this.message=t,e.length&&(this.acceptedTypes=e),this.acceptedTypes&&(this.hasErrors=this.checkTypeAndHasErrors(this.hasErrors.bind(this)))}getMessage(s,...t){return(0,utils_1.stringFormat)(s,...t)}checkTypeAndHasErrors(e){return function(s,...t){return void 0===s||!this.acceptedTypes||(0,utils_1.checkTypes)(s,this.acceptedTypes)?e(s,...t):this.getMessage(constants_1.DEFAULT_ERROR_MESSAGES.TYPE,this.acceptedTypes.join(", "),typeof s)}.bind(this)}}exports.Validator=Validator;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Errors } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* @summary Base Implementation for Validators
|
|
4
|
+
* @description Provides the underlying functionality for {@link Validator}s
|
|
5
|
+
*
|
|
6
|
+
* @param {string} validationKey the key to register the validator under
|
|
7
|
+
* @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES#DEFAULT}
|
|
8
|
+
* @param {string[]} [acceptedTypes] defines the value types this validator can validate
|
|
9
|
+
*
|
|
10
|
+
* @class Validator
|
|
11
|
+
* @abstract
|
|
12
|
+
* @category Validators
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class Validator {
|
|
15
|
+
readonly validationKey: string;
|
|
16
|
+
readonly message: string;
|
|
17
|
+
readonly acceptedTypes?: string[];
|
|
18
|
+
protected constructor(validationKey: string, message?: string, ...acceptedTypes: string[]);
|
|
19
|
+
/**
|
|
20
|
+
* @summary builds the error message
|
|
21
|
+
* @param {string} message
|
|
22
|
+
* @param {any[]} args
|
|
23
|
+
* @protected
|
|
24
|
+
*/
|
|
25
|
+
protected getMessage(message: string, ...args: any[]): string;
|
|
26
|
+
/**
|
|
27
|
+
* @summary Validates type
|
|
28
|
+
* @param {any} unbound
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
private checkTypeAndHasErrors;
|
|
32
|
+
/**
|
|
33
|
+
* @summary Validates an attribute
|
|
34
|
+
* @param {any} value
|
|
35
|
+
* @param {any[]} args
|
|
36
|
+
*
|
|
37
|
+
* @abstract
|
|
38
|
+
*
|
|
39
|
+
* @see Model#hasErrors
|
|
40
|
+
*/
|
|
41
|
+
abstract hasErrors(value: any, ...args: any[]): Errors;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function isValidator(t){return t.constructor&&t.hasErrors}Object.defineProperty(exports,"__esModule",{value:!0}),exports.ValidatorRegistry=exports.isValidator=void 0,exports.isValidator=isValidator;class ValidatorRegistry{constructor(...t){this.cache={},this.customKeyChache={},this.register(...t)}getCustomKeys(){return Object.assign({},this.customKeyChache)}getKeys(){return Object.keys(this.cache)}get(t){var e;if(t in this.cache)return isValidator(e=this.cache[t])?e:(e=new(e.default||e),this.cache[t]=e)}register(...t){t.forEach(t=>{var e,s;isValidator(t)?t.validationKey in this.cache||(this.cache[t.validationKey]=t):({validationKey:t,validator:s,save:e}=t,t in this.cache||(this.cache[t]=s,e&&((s={})[t.toUpperCase()]=t,this.customKeyChache=Object.assign({},this.customKeyChache,s))))})}}exports.ValidatorRegistry=ValidatorRegistry;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ValidatorDefinition } from "./types";
|
|
2
|
+
import { IValidatorRegistry } from "./types";
|
|
3
|
+
import type { Validator } from "./Validator";
|
|
4
|
+
/**
|
|
5
|
+
* @summary Duck typing for Validators
|
|
6
|
+
* @function isValidator
|
|
7
|
+
* @param val
|
|
8
|
+
*/
|
|
9
|
+
export declare function isValidator(val: any): any;
|
|
10
|
+
/**
|
|
11
|
+
* @summary Base Implementation of a Validator Registry
|
|
12
|
+
*
|
|
13
|
+
* @prop {Validator[]} [validators] the initial validators to register
|
|
14
|
+
*
|
|
15
|
+
* @class ValidatorRegistry
|
|
16
|
+
* @implements IValidatorRegistry<T>
|
|
17
|
+
*
|
|
18
|
+
* @category Validation
|
|
19
|
+
*/
|
|
20
|
+
export declare class ValidatorRegistry<T extends Validator> implements IValidatorRegistry<T> {
|
|
21
|
+
private cache;
|
|
22
|
+
private customKeyChache;
|
|
23
|
+
constructor(...validators: (ValidatorDefinition | Validator)[]);
|
|
24
|
+
/**
|
|
25
|
+
* @summary retrieves the custom keys
|
|
26
|
+
*/
|
|
27
|
+
getCustomKeys(): {
|
|
28
|
+
[indexer: string]: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* @summary retrieves the registered validators keys
|
|
32
|
+
*/
|
|
33
|
+
getKeys(): string[];
|
|
34
|
+
/**
|
|
35
|
+
* @summary Retrieves a validator
|
|
36
|
+
*
|
|
37
|
+
* @param {string} validatorKey one of the {@link ValidationKeys}
|
|
38
|
+
* @return {Validator | undefined} the registered Validator or undefined if there is nono matching the provided key
|
|
39
|
+
*/
|
|
40
|
+
get<T extends Validator>(validatorKey: string): T | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* @summary Registers the provided validators onto the registry
|
|
43
|
+
*
|
|
44
|
+
* @param {T[] | ValidatorDefinition[]} validator
|
|
45
|
+
*/
|
|
46
|
+
register<T extends Validator>(...validator: (ValidatorDefinition | T)[]): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PasswordPatterns=exports.DEFAULT_ERROR_MESSAGES=exports.DAYS_OF_WEEK_NAMES=exports.MONTH_NAMES=exports.ValidationKeys=void 0,exports.ValidationKeys={REFLECT:"model.validation.",REQUIRED:"required",MIN:"min",MAX:"max",STEP:"step",MIN_LENGTH:"minlength",MAX_LENGTH:"maxlength",PATTERN:"pattern",EMAIL:"email",URL:"url",DATE:"date",TYPE:"type",PASSWORD:"password",LIST:"list"},exports.MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],exports.DAYS_OF_WEEK_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],exports.DEFAULT_ERROR_MESSAGES={REQUIRED:"This field is required",MIN:"The minimum value is {0}",MAX:"The maximum value is {0}",MIN_LENGTH:"The minimum length is {0}",MAX_LENGTH:"The maximum length is {0}",PATTERN:"The value does not match the pattern",EMAIL:"The value is not a valid email",URL:"The value is not a valid URL",TYPE:"Invalid type. Expected {0}, received {1}",STEP:"Invalid value. Not a step of {0}",DATE:"Invalid value. not a valid Date",DEFAULT:"There is an Error",PASSWORD:"Must be at least 8 characters and contain one of number, lower and upper case letters, and special character (@$!%*?&_-.,)",LIST:"Invalid list of {0}",LIST_INSIDE:"Elements of list are invalid: {0}",MODEL_NOT_FOUND:"No model registered under {0}"},exports.PasswordPatterns={CHAR8_ONE_OF_EACH:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&_\-.,])[A-Za-z\d@$!%*?&_\-.,]{8,}$/g};
|