namefully 1.0.9 → 1.2.0
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 +21 -674
- package/dist/example/index.js +2734 -0
- package/dist/lib/config.d.ts +121 -0
- package/dist/lib/config.js +189 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/constants.d.ts +4 -0
- package/dist/lib/constants.js +31 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/error.d.ts +172 -0
- package/dist/lib/error.js +210 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/{usecases/index.d.ts → example/example.d.ts} +0 -0
- package/dist/lib/full-name.d.ts +71 -0
- package/dist/lib/full-name.js +147 -0
- package/dist/lib/full-name.js.map +1 -0
- package/dist/lib/index.d.ts +16 -6
- package/dist/lib/index.js +29 -8
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/name.d.ts +177 -0
- package/dist/lib/name.js +322 -0
- package/dist/lib/name.js.map +1 -0
- package/dist/lib/namefully.d.ts +303 -208
- package/dist/lib/namefully.js +603 -442
- package/dist/lib/namefully.js.map +1 -1
- package/dist/lib/parser.d.ts +46 -0
- package/dist/lib/parser.js +173 -0
- package/dist/lib/parser.js.map +1 -0
- package/dist/lib/src/config.d.ts +121 -0
- package/dist/lib/src/constants.d.ts +4 -0
- package/dist/lib/src/error.d.ts +172 -0
- package/dist/lib/src/full-name.d.ts +71 -0
- package/dist/lib/src/index.d.ts +16 -6
- package/dist/lib/src/name.d.ts +177 -0
- package/dist/lib/src/namefully.d.ts +303 -208
- package/dist/lib/src/parser.d.ts +46 -0
- package/dist/lib/src/types.d.ts +127 -0
- package/dist/lib/src/utils.d.ts +63 -0
- package/dist/lib/src/validator.d.ts +66 -0
- package/dist/lib/types.d.ts +127 -0
- package/dist/lib/types.js +181 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +63 -0
- package/dist/lib/utils.js +138 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/validator.d.ts +66 -0
- package/dist/lib/validator.js +332 -0
- package/dist/lib/validator.js.map +1 -0
- package/dist/umd/namefully.js +2191 -2111
- package/dist/umd/namefully.js.map +1 -1
- package/dist/umd/namefully.min.js +1 -1
- package/dist/umd/namefully.min.js.LICENSE.txt +8 -20
- package/dist/umd/namefully.min.js.map +1 -1
- package/package.json +50 -53
- package/readme.md +151 -175
- package/changelog.md +0 -114
- package/dist/lib/core/constants.d.ts +0 -26
- package/dist/lib/core/constants.js +0 -42
- package/dist/lib/core/constants.js.map +0 -1
- package/dist/lib/core/index.d.ts +0 -9
- package/dist/lib/core/index.js +0 -13
- package/dist/lib/core/index.js.map +0 -1
- package/dist/lib/core/parsers/array-name.parser.d.ts +0 -42
- package/dist/lib/core/parsers/array-name.parser.js +0 -84
- package/dist/lib/core/parsers/array-name.parser.js.map +0 -1
- package/dist/lib/core/parsers/array-string.parser.d.ts +0 -48
- package/dist/lib/core/parsers/array-string.parser.js +0 -96
- package/dist/lib/core/parsers/array-string.parser.js.map +0 -1
- package/dist/lib/core/parsers/index.d.ts +0 -11
- package/dist/lib/core/parsers/index.js +0 -11
- package/dist/lib/core/parsers/index.js.map +0 -1
- package/dist/lib/core/parsers/nama.parser.d.ts +0 -34
- package/dist/lib/core/parsers/nama.parser.js +0 -75
- package/dist/lib/core/parsers/nama.parser.js.map +0 -1
- package/dist/lib/core/parsers/parser.d.ts +0 -29
- package/dist/lib/core/parsers/parser.js +0 -3
- package/dist/lib/core/parsers/parser.js.map +0 -1
- package/dist/lib/core/parsers/string.parser.d.ts +0 -61
- package/dist/lib/core/parsers/string.parser.js +0 -63
- package/dist/lib/core/parsers/string.parser.js.map +0 -1
- package/dist/lib/core/utils/utils.d.ts +0 -14
- package/dist/lib/core/utils/utils.js +0 -67
- package/dist/lib/core/utils/utils.js.map +0 -1
- package/dist/lib/models/enums.d.ts +0 -91
- package/dist/lib/models/enums.js +0 -98
- package/dist/lib/models/enums.js.map +0 -1
- package/dist/lib/models/firstname.d.ts +0 -41
- package/dist/lib/models/firstname.js +0 -59
- package/dist/lib/models/firstname.js.map +0 -1
- package/dist/lib/models/index.d.ts +0 -12
- package/dist/lib/models/index.js +0 -15
- package/dist/lib/models/index.js.map +0 -1
- package/dist/lib/models/lastname.d.ts +0 -44
- package/dist/lib/models/lastname.js +0 -86
- package/dist/lib/models/lastname.js.map +0 -1
- package/dist/lib/models/misc.d.ts +0 -80
- package/dist/lib/models/misc.js +0 -3
- package/dist/lib/models/misc.js.map +0 -1
- package/dist/lib/models/name.d.ts +0 -48
- package/dist/lib/models/name.js +0 -72
- package/dist/lib/models/name.js.map +0 -1
- package/dist/lib/models/summary.d.ts +0 -23
- package/dist/lib/models/summary.js +0 -60
- package/dist/lib/models/summary.js.map +0 -1
- package/dist/lib/src/core/constants.d.ts +0 -26
- package/dist/lib/src/core/index.d.ts +0 -9
- package/dist/lib/src/core/parsers/array-name.parser.d.ts +0 -42
- package/dist/lib/src/core/parsers/array-string.parser.d.ts +0 -48
- package/dist/lib/src/core/parsers/index.d.ts +0 -11
- package/dist/lib/src/core/parsers/nama.parser.d.ts +0 -34
- package/dist/lib/src/core/parsers/parser.d.ts +0 -29
- package/dist/lib/src/core/parsers/string.parser.d.ts +0 -61
- package/dist/lib/src/core/utils/utils.d.ts +0 -14
- package/dist/lib/src/models/enums.d.ts +0 -91
- package/dist/lib/src/models/firstname.d.ts +0 -41
- package/dist/lib/src/models/index.d.ts +0 -12
- package/dist/lib/src/models/lastname.d.ts +0 -44
- package/dist/lib/src/models/misc.d.ts +0 -80
- package/dist/lib/src/models/name.d.ts +0 -48
- package/dist/lib/src/models/summary.d.ts +0 -23
- package/dist/lib/src/validators/array-name.validator.d.ts +0 -25
- package/dist/lib/src/validators/array-string.validator.d.ts +0 -43
- package/dist/lib/src/validators/common/validation-error.d.ts +0 -19
- package/dist/lib/src/validators/common/validation-rule.d.ts +0 -69
- package/dist/lib/src/validators/common/validation-type.d.ts +0 -24
- package/dist/lib/src/validators/firstname.validator.d.ts +0 -20
- package/dist/lib/src/validators/fullname.validator.d.ts +0 -21
- package/dist/lib/src/validators/index.d.ts +0 -21
- package/dist/lib/src/validators/lastname.validator.d.ts +0 -20
- package/dist/lib/src/validators/middlename.validator.d.ts +0 -20
- package/dist/lib/src/validators/nama.validator.d.ts +0 -21
- package/dist/lib/src/validators/namon.validator.d.ts +0 -20
- package/dist/lib/src/validators/prefix.validator.d.ts +0 -14
- package/dist/lib/src/validators/string-name.validator.d.ts +0 -20
- package/dist/lib/src/validators/suffix.validator.d.ts +0 -14
- package/dist/lib/src/validators/validator.d.ts +0 -13
- package/dist/lib/usecases/compress.usecase.d.ts +0 -8
- package/dist/lib/usecases/constants.d.ts +0 -7
- package/dist/lib/usecases/describe.usecase.d.ts +0 -12
- package/dist/lib/usecases/format.usecase.d.ts +0 -6
- package/dist/lib/usecases/namefully.usecase.d.ts +0 -14
- package/dist/lib/usecases/shorten.usecase.d.ts +0 -6
- package/dist/lib/validators/array-name.validator.d.ts +0 -25
- package/dist/lib/validators/array-name.validator.js +0 -82
- package/dist/lib/validators/array-name.validator.js.map +0 -1
- package/dist/lib/validators/array-string.validator.d.ts +0 -43
- package/dist/lib/validators/array-string.validator.js +0 -80
- package/dist/lib/validators/array-string.validator.js.map +0 -1
- package/dist/lib/validators/common/validation-error.d.ts +0 -19
- package/dist/lib/validators/common/validation-error.js +0 -26
- package/dist/lib/validators/common/validation-error.js.map +0 -1
- package/dist/lib/validators/common/validation-rule.d.ts +0 -69
- package/dist/lib/validators/common/validation-rule.js +0 -73
- package/dist/lib/validators/common/validation-rule.js.map +0 -1
- package/dist/lib/validators/common/validation-type.d.ts +0 -24
- package/dist/lib/validators/common/validation-type.js +0 -28
- package/dist/lib/validators/common/validation-type.js.map +0 -1
- package/dist/lib/validators/firstname.validator.d.ts +0 -20
- package/dist/lib/validators/firstname.validator.js +0 -29
- package/dist/lib/validators/firstname.validator.js.map +0 -1
- package/dist/lib/validators/fullname.validator.d.ts +0 -21
- package/dist/lib/validators/fullname.validator.js +0 -38
- package/dist/lib/validators/fullname.validator.js.map +0 -1
- package/dist/lib/validators/index.d.ts +0 -21
- package/dist/lib/validators/index.js +0 -35
- package/dist/lib/validators/index.js.map +0 -1
- package/dist/lib/validators/lastname.validator.d.ts +0 -20
- package/dist/lib/validators/lastname.validator.js +0 -29
- package/dist/lib/validators/lastname.validator.js.map +0 -1
- package/dist/lib/validators/middlename.validator.d.ts +0 -20
- package/dist/lib/validators/middlename.validator.js +0 -38
- package/dist/lib/validators/middlename.validator.js.map +0 -1
- package/dist/lib/validators/nama.validator.d.ts +0 -21
- package/dist/lib/validators/nama.validator.js +0 -43
- package/dist/lib/validators/nama.validator.js.map +0 -1
- package/dist/lib/validators/namon.validator.d.ts +0 -20
- package/dist/lib/validators/namon.validator.js +0 -29
- package/dist/lib/validators/namon.validator.js.map +0 -1
- package/dist/lib/validators/prefix.validator.d.ts +0 -14
- package/dist/lib/validators/prefix.validator.js +0 -31
- package/dist/lib/validators/prefix.validator.js.map +0 -1
- package/dist/lib/validators/string-name.validator.d.ts +0 -20
- package/dist/lib/validators/string-name.validator.js +0 -29
- package/dist/lib/validators/string-name.validator.js.map +0 -1
- package/dist/lib/validators/suffix.validator.d.ts +0 -14
- package/dist/lib/validators/suffix.validator.js +0 -31
- package/dist/lib/validators/suffix.validator.js.map +0 -1
- package/dist/lib/validators/validator.d.ts +0 -13
- package/dist/lib/validators/validator.js +0 -9
- package/dist/lib/validators/validator.js.map +0 -1
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Validator, ValidatorType } from './index';
|
|
2
|
-
/**
|
|
3
|
-
* Represents a prefix validator
|
|
4
|
-
* @class
|
|
5
|
-
* @implements {Validator}
|
|
6
|
-
*/
|
|
7
|
-
export default class PrefixValidator implements Validator<string> {
|
|
8
|
-
readonly type: ValidatorType;
|
|
9
|
-
/**
|
|
10
|
-
* Validates the content of a prefix name
|
|
11
|
-
* @param {string} value data to validate
|
|
12
|
-
*/
|
|
13
|
-
validate(value: string): void;
|
|
14
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* String of full name validator
|
|
3
|
-
*
|
|
4
|
-
* Created on March 15, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
import { Validator, ValidatorType } from './index';
|
|
8
|
-
/**
|
|
9
|
-
* Represents a string full name validator
|
|
10
|
-
* @class
|
|
11
|
-
* @implements {Validator}
|
|
12
|
-
*/
|
|
13
|
-
export default class StringNameValidator implements Validator<string> {
|
|
14
|
-
readonly type: ValidatorType;
|
|
15
|
-
/**
|
|
16
|
-
* Validates the content of a name
|
|
17
|
-
* @param {string} value data to validate
|
|
18
|
-
*/
|
|
19
|
-
validate(value: string): void;
|
|
20
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Validator, ValidatorType } from './index';
|
|
2
|
-
/**
|
|
3
|
-
* Represents a suffix validator
|
|
4
|
-
* @class
|
|
5
|
-
* @implements {Validator}
|
|
6
|
-
*/
|
|
7
|
-
export default class SuffixValidator implements Validator<string> {
|
|
8
|
-
readonly type: ValidatorType;
|
|
9
|
-
/**
|
|
10
|
-
* Validates the content of a suffix name
|
|
11
|
-
* @param {string} value data to validate
|
|
12
|
-
*/
|
|
13
|
-
validate(value: string): void;
|
|
14
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A `Validator` contract
|
|
3
|
-
*
|
|
4
|
-
* Created on March 06, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Interface for a JSON signature that represents a generic validator
|
|
9
|
-
* @interface
|
|
10
|
-
*/
|
|
11
|
-
export interface Validator<T> {
|
|
12
|
-
validate(value: T): void;
|
|
13
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare function describeFullnameUseCase(): void;
|
|
2
|
-
declare function describeFirstnameUseCase(): void;
|
|
3
|
-
declare function describeMiddlenameUseCase(): void;
|
|
4
|
-
declare function describeLastnameUseCase(): void;
|
|
5
|
-
export { describeFullnameUseCase, describeFirstnameUseCase, describeMiddlenameUseCase, describeLastnameUseCase, };
|
|
6
|
-
declare const _default: {
|
|
7
|
-
describeFullnameUseCase: typeof describeFullnameUseCase;
|
|
8
|
-
describeFirstnameUseCase: typeof describeFirstnameUseCase;
|
|
9
|
-
describeMiddlenameUseCase: typeof describeMiddlenameUseCase;
|
|
10
|
-
describeLastnameUseCase: typeof describeLastnameUseCase;
|
|
11
|
-
};
|
|
12
|
-
export default _default;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
declare function createFromLiteralStringUseCase(): void;
|
|
2
|
-
declare function createFromArrayStringUseCase(): void;
|
|
3
|
-
declare function createFromArrayNameUseCase(): void;
|
|
4
|
-
declare function createFromArrayNamaUseCase(): void;
|
|
5
|
-
declare function createWithOptionalParamsUseCase(): void;
|
|
6
|
-
export { createFromLiteralStringUseCase, createFromArrayStringUseCase, createFromArrayNameUseCase, createFromArrayNamaUseCase, createWithOptionalParamsUseCase, };
|
|
7
|
-
declare const _default: {
|
|
8
|
-
createFromLiteralStringUseCase: typeof createFromLiteralStringUseCase;
|
|
9
|
-
createFromArrayStringUseCase: typeof createFromArrayStringUseCase;
|
|
10
|
-
createFromArrayNameUseCase: typeof createFromArrayNameUseCase;
|
|
11
|
-
createFromArrayNamaUseCase: typeof createFromArrayNamaUseCase;
|
|
12
|
-
createWithOptionalParamsUseCase: typeof createWithOptionalParamsUseCase;
|
|
13
|
-
};
|
|
14
|
-
export default _default;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Array of `Name` validator
|
|
3
|
-
*
|
|
4
|
-
* Created on March 15, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
import { Name } from '../models/index';
|
|
8
|
-
import { Validator, ValidatorType } from './index';
|
|
9
|
-
/**
|
|
10
|
-
* Represents a validator to help the array `Name` parser
|
|
11
|
-
* @class
|
|
12
|
-
* @classdesc
|
|
13
|
-
* This validator validates a array of `Name` objects following a specific order
|
|
14
|
-
* based on the count of elements. It is expected that the array has to be
|
|
15
|
-
* between two and five elements.
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
export default class ArrayNameValidator implements Validator<Name[]> {
|
|
19
|
-
readonly type: ValidatorType;
|
|
20
|
-
/**
|
|
21
|
-
* Validates the content of a set of custom `Name`s
|
|
22
|
-
* @param {Array<Name>} value data to validate
|
|
23
|
-
*/
|
|
24
|
-
validate(values: Array<Name>): void;
|
|
25
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Array of `Name` validator
|
|
5
|
-
*
|
|
6
|
-
* Created on March 15, 2020
|
|
7
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
8
|
-
*/
|
|
9
|
-
const index_1 = require("../models/index");
|
|
10
|
-
const index_2 = require("./index");
|
|
11
|
-
/**
|
|
12
|
-
* Represents a validator to help the array `Name` parser
|
|
13
|
-
* @class
|
|
14
|
-
* @classdesc
|
|
15
|
-
* This validator validates a array of `Name` objects following a specific order
|
|
16
|
-
* based on the count of elements. It is expected that the array has to be
|
|
17
|
-
* between two and five elements.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
class ArrayNameValidator {
|
|
21
|
-
constructor() {
|
|
22
|
-
this.type = index_2.ValidatorType.ARR_NAMES;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Validates the content of a set of custom `Name`s
|
|
26
|
-
* @param {Array<Name>} value data to validate
|
|
27
|
-
*/
|
|
28
|
-
validate(values) {
|
|
29
|
-
if (values.length <= 1 || values.length > 5) {
|
|
30
|
-
throw new index_2.ValidationError(`must be an array of 2 - 5 'Name's`, 'Array of Names');
|
|
31
|
-
}
|
|
32
|
-
const validators = {
|
|
33
|
-
[index_1.Namon.PREFIX]: new index_2.PrefixValidator(),
|
|
34
|
-
[index_1.Namon.FIRST_NAME]: new index_2.FirstnameValidator(),
|
|
35
|
-
[index_1.Namon.MIDDLE_NAME]: new index_2.MiddlenameValidator(),
|
|
36
|
-
[index_1.Namon.LAST_NAME]: new index_2.LastnameValidator(),
|
|
37
|
-
[index_1.Namon.SUFFIX]: new index_2.SuffixValidator(),
|
|
38
|
-
};
|
|
39
|
-
switch (values.length) {
|
|
40
|
-
case 2: // first name + last name
|
|
41
|
-
values.forEach(n => {
|
|
42
|
-
if (![index_1.Namon.FIRST_NAME, index_1.Namon.LAST_NAME].includes(n.type))
|
|
43
|
-
throw new index_2.ValidationError('Both first and last names are required');
|
|
44
|
-
if (n.type === index_1.Namon.LAST_NAME && n instanceof index_1.Lastname)
|
|
45
|
-
validators[n.type].validate(n.mother);
|
|
46
|
-
validators[n.type].validate(n.namon);
|
|
47
|
-
});
|
|
48
|
-
break;
|
|
49
|
-
case 3: // first name + middle name + last name
|
|
50
|
-
values.forEach(n => {
|
|
51
|
-
if (![index_1.Namon.FIRST_NAME, index_1.Namon.MIDDLE_NAME, index_1.Namon.LAST_NAME].includes(n.type))
|
|
52
|
-
throw new index_2.ValidationError('First, middle and last names are required');
|
|
53
|
-
if (n.type === index_1.Namon.LAST_NAME && n instanceof index_1.Lastname)
|
|
54
|
-
validators[n.type].validate(n.mother);
|
|
55
|
-
validators[n.type].validate(n.namon);
|
|
56
|
-
});
|
|
57
|
-
break;
|
|
58
|
-
case 4: // first name + middle name + last name
|
|
59
|
-
values.forEach(n => {
|
|
60
|
-
if (![index_1.Namon.PREFIX, index_1.Namon.FIRST_NAME, index_1.Namon.MIDDLE_NAME,
|
|
61
|
-
index_1.Namon.LAST_NAME].includes(n.type))
|
|
62
|
-
throw new index_2.ValidationError('More fields are required');
|
|
63
|
-
if (n.type === index_1.Namon.LAST_NAME && n instanceof index_1.Lastname)
|
|
64
|
-
validators[n.type].validate(n.mother);
|
|
65
|
-
validators[n.type].validate(n.namon);
|
|
66
|
-
});
|
|
67
|
-
break;
|
|
68
|
-
case 5: // first name + middle name + last name
|
|
69
|
-
values.forEach(n => {
|
|
70
|
-
if (![index_1.Namon.PREFIX, index_1.Namon.FIRST_NAME, index_1.Namon.MIDDLE_NAME, index_1.Namon.LAST_NAME,
|
|
71
|
-
index_1.Namon.SUFFIX].includes(n.type))
|
|
72
|
-
throw new index_2.ValidationError('More fields are required');
|
|
73
|
-
if (n.type === index_1.Namon.LAST_NAME && n instanceof index_1.Lastname)
|
|
74
|
-
validators[n.type].validate(n.mother);
|
|
75
|
-
validators[n.type].validate(n.namon);
|
|
76
|
-
});
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.default = ArrayNameValidator;
|
|
82
|
-
//# sourceMappingURL=array-name.validator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array-name.validator.js","sourceRoot":"","sources":["../../../src/validators/array-name.validator.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,2CAAwD;AACxD,mCAGiB;AAEjB;;;;;;;;GAQG;AACH,MAAqB,kBAAkB;IAAvC;QACa,SAAI,GAAkB,qBAAa,CAAC,SAAS,CAAC;IA0D3D,CAAC;IAzDG;;;OAGG;IACH,QAAQ,CAAC,MAAmB;QACxB,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACzC,MAAM,IAAI,uBAAe,CAAC,mCAAmC,EAAE,gBAAgB,CAAC,CAAC;SACpF;QACD,MAAM,UAAU,GAAG;YACf,CAAC,aAAK,CAAC,MAAM,CAAC,EAAE,IAAI,uBAAe,EAAE;YACrC,CAAC,aAAK,CAAC,UAAU,CAAC,EAAE,IAAI,0BAAkB,EAAE;YAC5C,CAAC,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oBACzC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;gBACxC,CAAC,CAAC,CAAC;gBACH,MAAM;SACb;IACL,CAAC;CACJ;AA3DD,qCA2DC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Array of string validator
|
|
3
|
-
*
|
|
4
|
-
* Created on March 15, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
import { Validator, ValidatorType } from './index';
|
|
8
|
-
import { NameIndex } from '../models/index';
|
|
9
|
-
/**
|
|
10
|
-
* Represents a validator to help the array string parser
|
|
11
|
-
* @class
|
|
12
|
-
* @classdesc
|
|
13
|
-
* This validator validates an array of string name following a specific order
|
|
14
|
-
* based on the count of elements. It is expected that the array has to be between
|
|
15
|
-
* two and five elements. Also, the order of appearance set in the configuration
|
|
16
|
-
* influences how this validation is carried out.
|
|
17
|
-
*
|
|
18
|
-
* Ordered by first name, the validator validates the following:
|
|
19
|
-
* - 2 elements: firstname lastname
|
|
20
|
-
* - 3 elements: firstname middlename lastname
|
|
21
|
-
* - 4 elements: prefix firstname middlename lastname
|
|
22
|
-
* - 5 elements: prefix firstname middlename lastname suffix
|
|
23
|
-
*
|
|
24
|
-
* Ordered by last name, the validator validates the following:
|
|
25
|
-
* - 2 elements: lastname firstname
|
|
26
|
-
* - 3 elements: lastname firstname middlename
|
|
27
|
-
* - 4 elements: prefix lastname firstname middlename
|
|
28
|
-
* - 5 elements: prefix lastname firstname middlename suffix
|
|
29
|
-
*/
|
|
30
|
-
export default class ArrayStringValidator implements Validator<string[]> {
|
|
31
|
-
indexing: NameIndex;
|
|
32
|
-
readonly type: ValidatorType;
|
|
33
|
-
/**
|
|
34
|
-
* Creates an instance of the validator
|
|
35
|
-
* @param indexing how to index the name parts
|
|
36
|
-
*/
|
|
37
|
-
constructor(indexing: NameIndex);
|
|
38
|
-
/**
|
|
39
|
-
* Validates the content of a name
|
|
40
|
-
* @param {string} value data to validate
|
|
41
|
-
*/
|
|
42
|
-
validate(values: string[]): void;
|
|
43
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Array of string validator
|
|
5
|
-
*
|
|
6
|
-
* Created on March 15, 2020
|
|
7
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
8
|
-
*/
|
|
9
|
-
const index_1 = require("./index");
|
|
10
|
-
/**
|
|
11
|
-
* Represents a validator to help the array string parser
|
|
12
|
-
* @class
|
|
13
|
-
* @classdesc
|
|
14
|
-
* This validator validates an array of string name following a specific order
|
|
15
|
-
* based on the count of elements. It is expected that the array has to be between
|
|
16
|
-
* two and five elements. Also, the order of appearance set in the configuration
|
|
17
|
-
* influences how this validation is carried out.
|
|
18
|
-
*
|
|
19
|
-
* Ordered by first name, the validator validates the following:
|
|
20
|
-
* - 2 elements: firstname lastname
|
|
21
|
-
* - 3 elements: firstname middlename lastname
|
|
22
|
-
* - 4 elements: prefix firstname middlename lastname
|
|
23
|
-
* - 5 elements: prefix firstname middlename lastname suffix
|
|
24
|
-
*
|
|
25
|
-
* Ordered by last name, the validator validates the following:
|
|
26
|
-
* - 2 elements: lastname firstname
|
|
27
|
-
* - 3 elements: lastname firstname middlename
|
|
28
|
-
* - 4 elements: prefix lastname firstname middlename
|
|
29
|
-
* - 5 elements: prefix lastname firstname middlename suffix
|
|
30
|
-
*/
|
|
31
|
-
class ArrayStringValidator {
|
|
32
|
-
/**
|
|
33
|
-
* Creates an instance of the validator
|
|
34
|
-
* @param indexing how to index the name parts
|
|
35
|
-
*/
|
|
36
|
-
constructor(indexing) {
|
|
37
|
-
this.indexing = indexing;
|
|
38
|
-
this.type = index_1.ValidatorType.ARR_STRING;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Validates the content of a name
|
|
42
|
-
* @param {string} value data to validate
|
|
43
|
-
*/
|
|
44
|
-
validate(values) {
|
|
45
|
-
if (values.length <= 1 || values.length > 5)
|
|
46
|
-
throw new index_1.ValidationError('must be an array of 2 - 5 elements', 'Array of names');
|
|
47
|
-
const pf = new index_1.PrefixValidator();
|
|
48
|
-
const sf = new index_1.SuffixValidator();
|
|
49
|
-
const fn = new index_1.FirstnameValidator();
|
|
50
|
-
const ln = new index_1.LastnameValidator();
|
|
51
|
-
const mn = new index_1.MiddlenameValidator();
|
|
52
|
-
const index = this.indexing;
|
|
53
|
-
switch (values.length) {
|
|
54
|
-
case 2:
|
|
55
|
-
fn.validate(values[index.firstname]);
|
|
56
|
-
ln.validate(values[index.lastname]);
|
|
57
|
-
break;
|
|
58
|
-
case 3:
|
|
59
|
-
fn.validate(values[index.firstname]);
|
|
60
|
-
mn.validate(values[index.middlename]);
|
|
61
|
-
ln.validate(values[index.lastname]);
|
|
62
|
-
break;
|
|
63
|
-
case 4:
|
|
64
|
-
pf.validate(values[index.prefix]);
|
|
65
|
-
fn.validate(values[index.firstname]);
|
|
66
|
-
mn.validate(values[index.middlename]);
|
|
67
|
-
ln.validate(values[index.lastname]);
|
|
68
|
-
break;
|
|
69
|
-
case 5:
|
|
70
|
-
pf.validate(values[index.prefix]);
|
|
71
|
-
fn.validate(values[index.firstname]);
|
|
72
|
-
mn.validate(values[index.middlename]);
|
|
73
|
-
ln.validate(values[index.lastname]);
|
|
74
|
-
sf.validate(values[index.suffix]);
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.default = ArrayStringValidator;
|
|
80
|
-
//# sourceMappingURL=array-string.validator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array-string.validator.js","sourceRoot":"","sources":["../../../src/validators/array-string.validator.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,mCAGiB;AAGjB;;;;;;;;;;;;;;;;;;;;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AAC;gBAClC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;gBACrC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;gBACtC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACpC,MAAM;YACV,KAAK,CAAC;gBACF,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;gBAClC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;gBACrC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;gBACtC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACpC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;gBACjC,MAAM;SACb;IACL,CAAC;CACJ;AAnDD,uCAmDC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validation error
|
|
3
|
-
*
|
|
4
|
-
* Created on March 06, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Represents a validation error
|
|
9
|
-
* @class
|
|
10
|
-
* @extends Error
|
|
11
|
-
*/
|
|
12
|
-
export declare class ValidationError extends Error {
|
|
13
|
-
/**
|
|
14
|
-
* Create a validation `Error`
|
|
15
|
-
* @param message of error to display
|
|
16
|
-
* @param type categorizes the error
|
|
17
|
-
*/
|
|
18
|
-
constructor(message?: string, type?: string);
|
|
19
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Validation error
|
|
4
|
-
*
|
|
5
|
-
* Created on March 06, 2020
|
|
6
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
/**
|
|
10
|
-
* Represents a validation error
|
|
11
|
-
* @class
|
|
12
|
-
* @extends Error
|
|
13
|
-
*/
|
|
14
|
-
class ValidationError extends Error {
|
|
15
|
-
/**
|
|
16
|
-
* Create a validation `Error`
|
|
17
|
-
* @param message of error to display
|
|
18
|
-
* @param type categorizes the error
|
|
19
|
-
*/
|
|
20
|
-
constructor(message, type) {
|
|
21
|
-
super(`${type ? type + ' :: ' + message : message}`);
|
|
22
|
-
this.name = 'ValidationError';
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.ValidationError = ValidationError;
|
|
26
|
-
//# sourceMappingURL=validation-error.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation-error.js","sourceRoot":"","sources":["../../../../src/validators/common/validation-error.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,KAAK;IACtC;;;;OAIG;IACH,YAAY,OAAgB,EAAE,IAAa;QACvC,KAAK,CAAC,GAAI,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,OAAQ,EAAE,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAClC,CAAC;CACJ;AAVD,0CAUC"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validation rules
|
|
3
|
-
*
|
|
4
|
-
* Created on March 06, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Represents a set of validation rules (regex)
|
|
9
|
-
* @class
|
|
10
|
-
* @static
|
|
11
|
-
*
|
|
12
|
-
* This regex is intented to match specific alphabets only as a person name does
|
|
13
|
-
* not contain special characters. `\w` does not cover non-Latin characters. So,
|
|
14
|
-
* it is extended using unicode chars to cover more cases (e.g., Icelandic).
|
|
15
|
-
* It matches as follows:
|
|
16
|
-
* [a-z]: Latin alphabet from a (index 97) to z (index 122)
|
|
17
|
-
* [A-Z]: Latin alphabet from A (index 65) to Z (index 90)
|
|
18
|
-
* [\u00C0-\u00D6]: Latin/German chars from À (index 192) to Ö (index 214)
|
|
19
|
-
* [\u00D8-\u00f6]: German/Icelandic chars from Ø (index 216) to ö (index 246)
|
|
20
|
-
* [\u00f8-\u00ff]: German/Icelandic chars from ø (index 248) to ÿ (index 255)
|
|
21
|
-
* [\u0400-\u04FF]: Cyrillic alphabet from Ѐ (index 1024) to ӿ (index 1279)
|
|
22
|
-
* [\u04FFΆ-ωΑ-ώ]: Greek alphabet from Ά (index 902) to ω (index 969)
|
|
23
|
-
*/
|
|
24
|
-
export declare class ValidationRule {
|
|
25
|
-
/**
|
|
26
|
-
* Matches one name part (namon) that is of nature:
|
|
27
|
-
* - Latin (English, Spanish, French, etc.)
|
|
28
|
-
* - European (Greek, Cyrillic, Icelandic, German)
|
|
29
|
-
* - hyphenated
|
|
30
|
-
* - with apostrophe
|
|
31
|
-
*/
|
|
32
|
-
static namon: RegExp;
|
|
33
|
-
/**
|
|
34
|
-
* Matches 1+ name parts (namon) that are of nature:
|
|
35
|
-
* - Latin (English, Spanish, French, etc.)
|
|
36
|
-
* - European (Greek, Cyrillic, Icelandic, German)
|
|
37
|
-
* - hyphenated
|
|
38
|
-
* - with apostrophe
|
|
39
|
-
* - with comma
|
|
40
|
-
* - with period
|
|
41
|
-
* - with space
|
|
42
|
-
*/
|
|
43
|
-
static fullname: RegExp;
|
|
44
|
-
/**
|
|
45
|
-
* Matches one name part (namon) that is of nature:
|
|
46
|
-
* - Latin (English, Spanish, French, etc.)
|
|
47
|
-
* - European (Greek, Cyrillic, Icelandic, German)
|
|
48
|
-
* - hyphenated
|
|
49
|
-
* - with apostrophe
|
|
50
|
-
*/
|
|
51
|
-
static firstname: RegExp;
|
|
52
|
-
/**
|
|
53
|
-
* Matches 1+ names part (namon) that are of nature:
|
|
54
|
-
* - Latin (English, Spanish, French, etc.)
|
|
55
|
-
* - European (Greek, Cyrillic, Icelandic, German)
|
|
56
|
-
* - hyphenated
|
|
57
|
-
* - with apostrophe
|
|
58
|
-
* - with space
|
|
59
|
-
*/
|
|
60
|
-
static middlename: RegExp;
|
|
61
|
-
/**
|
|
62
|
-
* Matches one name part (namon) that is of nature:
|
|
63
|
-
* - Latin (English, Spanish, French, etc.)
|
|
64
|
-
* - European (Greek, Cyrillic, Icelandic, German)
|
|
65
|
-
* - hyphenated
|
|
66
|
-
* - with apostrophe
|
|
67
|
-
*/
|
|
68
|
-
static lastname: RegExp;
|
|
69
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Validation rules
|
|
4
|
-
*
|
|
5
|
-
* Created on March 06, 2020
|
|
6
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
/**
|
|
10
|
-
* Represents a set of validation rules (regex)
|
|
11
|
-
* @class
|
|
12
|
-
* @static
|
|
13
|
-
*
|
|
14
|
-
* This regex is intented to match specific alphabets only as a person name does
|
|
15
|
-
* not contain special characters. `\w` does not cover non-Latin characters. So,
|
|
16
|
-
* it is extended using unicode chars to cover more cases (e.g., Icelandic).
|
|
17
|
-
* It matches as follows:
|
|
18
|
-
* [a-z]: Latin alphabet from a (index 97) to z (index 122)
|
|
19
|
-
* [A-Z]: Latin alphabet from A (index 65) to Z (index 90)
|
|
20
|
-
* [\u00C0-\u00D6]: Latin/German chars from À (index 192) to Ö (index 214)
|
|
21
|
-
* [\u00D8-\u00f6]: German/Icelandic chars from Ø (index 216) to ö (index 246)
|
|
22
|
-
* [\u00f8-\u00ff]: German/Icelandic chars from ø (index 248) to ÿ (index 255)
|
|
23
|
-
* [\u0400-\u04FF]: Cyrillic alphabet from Ѐ (index 1024) to ӿ (index 1279)
|
|
24
|
-
* [\u04FFΆ-ωΑ-ώ]: Greek alphabet from Ά (index 902) to ω (index 969)
|
|
25
|
-
*/
|
|
26
|
-
class ValidationRule {
|
|
27
|
-
}
|
|
28
|
-
exports.ValidationRule = ValidationRule;
|
|
29
|
-
/**
|
|
30
|
-
* Matches one name part (namon) that is of nature:
|
|
31
|
-
* - Latin (English, Spanish, French, etc.)
|
|
32
|
-
* - European (Greek, Cyrillic, Icelandic, German)
|
|
33
|
-
* - hyphenated
|
|
34
|
-
* - with apostrophe
|
|
35
|
-
*/
|
|
36
|
-
ValidationRule.namon = /^[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ]+((['-][a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ])?[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ]*)*$/;
|
|
37
|
-
/**
|
|
38
|
-
* Matches 1+ name parts (namon) that are of nature:
|
|
39
|
-
* - Latin (English, Spanish, French, etc.)
|
|
40
|
-
* - European (Greek, Cyrillic, Icelandic, German)
|
|
41
|
-
* - hyphenated
|
|
42
|
-
* - with apostrophe
|
|
43
|
-
* - with comma
|
|
44
|
-
* - with period
|
|
45
|
-
* - with space
|
|
46
|
-
*/
|
|
47
|
-
ValidationRule.fullname = /^[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ]+(([',. -][a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ ])?[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ]*)*$/;
|
|
48
|
-
/**
|
|
49
|
-
* Matches one name part (namon) that is of nature:
|
|
50
|
-
* - Latin (English, Spanish, French, etc.)
|
|
51
|
-
* - European (Greek, Cyrillic, Icelandic, German)
|
|
52
|
-
* - hyphenated
|
|
53
|
-
* - with apostrophe
|
|
54
|
-
*/
|
|
55
|
-
ValidationRule.firstname = /^[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ]+((['-][a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ])?[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ]*)*$/;
|
|
56
|
-
/**
|
|
57
|
-
* Matches 1+ names part (namon) that are of nature:
|
|
58
|
-
* - Latin (English, Spanish, French, etc.)
|
|
59
|
-
* - European (Greek, Cyrillic, Icelandic, German)
|
|
60
|
-
* - hyphenated
|
|
61
|
-
* - with apostrophe
|
|
62
|
-
* - with space
|
|
63
|
-
*/
|
|
64
|
-
ValidationRule.middlename = /^[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ]+(([' -][a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ])?[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ]*)*$/;
|
|
65
|
-
/**
|
|
66
|
-
* Matches one name part (namon) that is of nature:
|
|
67
|
-
* - Latin (English, Spanish, French, etc.)
|
|
68
|
-
* - European (Greek, Cyrillic, Icelandic, German)
|
|
69
|
-
* - hyphenated
|
|
70
|
-
* - with apostrophe
|
|
71
|
-
*/
|
|
72
|
-
ValidationRule.lastname = /^[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ]+((['-][a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ])?[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ]*)*$/;
|
|
73
|
-
//# sourceMappingURL=validation-rule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation-rule.js","sourceRoot":"","sources":["../../../../src/validators/common/validation-rule.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,cAAc;;AAA3B,wCAiDC;AAhDG;;;;;;GAMG;AACI,oBAAK,GAAW,sNAAsN,CAAA;AAE7O;;;;;;;;;GASG;AACI,uBAAQ,GAAW,0NAA0N,CAAA;AAEpP;;;;;;GAMG;AACI,wBAAS,GAAW,sNAAsN,CAAA;AAEjP;;;;;;;GAOG;AACI,yBAAU,GAAW,uNAAuN,CAAA;AAEnP;;;;;;GAMG;AACI,uBAAQ,GAAW,sNAAsN,CAAA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validation types
|
|
3
|
-
*
|
|
4
|
-
* Created on March 06, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Enum for the validation types
|
|
9
|
-
* @enum
|
|
10
|
-
*/
|
|
11
|
-
export declare enum ValidatorType {
|
|
12
|
-
NONE = 0,
|
|
13
|
-
NAMON = 1,
|
|
14
|
-
NAMA = 2,
|
|
15
|
-
ARR_NAMES = 3,
|
|
16
|
-
ARR_STRING = 4,
|
|
17
|
-
FULL_NAME = 5,
|
|
18
|
-
PREFIX = 6,
|
|
19
|
-
FIRST_NAME = 7,
|
|
20
|
-
MIDDLE_NAME = 8,
|
|
21
|
-
LAST_NAME = 9,
|
|
22
|
-
SUFFIX = 10,
|
|
23
|
-
CUSTOM = 11
|
|
24
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Validation types
|
|
4
|
-
*
|
|
5
|
-
* Created on March 06, 2020
|
|
6
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
/**
|
|
10
|
-
* Enum for the validation types
|
|
11
|
-
* @enum
|
|
12
|
-
*/
|
|
13
|
-
var ValidatorType;
|
|
14
|
-
(function (ValidatorType) {
|
|
15
|
-
ValidatorType[ValidatorType["NONE"] = 0] = "NONE";
|
|
16
|
-
ValidatorType[ValidatorType["NAMON"] = 1] = "NAMON";
|
|
17
|
-
ValidatorType[ValidatorType["NAMA"] = 2] = "NAMA";
|
|
18
|
-
ValidatorType[ValidatorType["ARR_NAMES"] = 3] = "ARR_NAMES";
|
|
19
|
-
ValidatorType[ValidatorType["ARR_STRING"] = 4] = "ARR_STRING";
|
|
20
|
-
ValidatorType[ValidatorType["FULL_NAME"] = 5] = "FULL_NAME";
|
|
21
|
-
ValidatorType[ValidatorType["PREFIX"] = 6] = "PREFIX";
|
|
22
|
-
ValidatorType[ValidatorType["FIRST_NAME"] = 7] = "FIRST_NAME";
|
|
23
|
-
ValidatorType[ValidatorType["MIDDLE_NAME"] = 8] = "MIDDLE_NAME";
|
|
24
|
-
ValidatorType[ValidatorType["LAST_NAME"] = 9] = "LAST_NAME";
|
|
25
|
-
ValidatorType[ValidatorType["SUFFIX"] = 10] = "SUFFIX";
|
|
26
|
-
ValidatorType[ValidatorType["CUSTOM"] = 11] = "CUSTOM";
|
|
27
|
-
})(ValidatorType = exports.ValidatorType || (exports.ValidatorType = {}));
|
|
28
|
-
//# sourceMappingURL=validation-type.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation-type.js","sourceRoot":"","sources":["../../../../src/validators/common/validation-type.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH;;;GAGG;AACH,IAAY,aAcX;AAdD,WAAY,aAAa;IACrB,iDAAI,CAAA;IACJ,mDAAK,CAAA;IACL,iDAAI,CAAA;IACJ,2DAAS,CAAA;IACT,6DAAU,CAAA;IACV,2DAAS,CAAA;IACT,qDAAM,CAAA;IACN,6DAAU,CAAA;IACV,+DAAW,CAAA;IACX,2DAAS,CAAA;IACT,sDAAM,CAAA;IAEN,sDAAM,CAAA;AACV,CAAC,EAdW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAcxB"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* First name validator
|
|
3
|
-
*
|
|
4
|
-
* Created on March 15, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
import { Validator, ValidatorType } from './index';
|
|
8
|
-
/**
|
|
9
|
-
* Represents a first name validator
|
|
10
|
-
* @class
|
|
11
|
-
* @implements {Validator}
|
|
12
|
-
*/
|
|
13
|
-
export default class FirstnameValidator implements Validator<string> {
|
|
14
|
-
readonly type: ValidatorType;
|
|
15
|
-
/**
|
|
16
|
-
* Validates the content of a first name
|
|
17
|
-
* @param {string} value data to validate
|
|
18
|
-
*/
|
|
19
|
-
validate(value: string): void;
|
|
20
|
-
}
|