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,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* All the enums are listed here
|
|
3
|
-
*
|
|
4
|
-
* Created on March 06, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Enum `Namon` contains the finite set of a representative piece of a name
|
|
9
|
-
* @readonly
|
|
10
|
-
* @enum {string}
|
|
11
|
-
* The word `Namon` is the singular form used to refer to a chunk|part|piece of
|
|
12
|
-
* a name. And the plural form is `Nama`. (Same idea as in criterion/criteria)
|
|
13
|
-
*/
|
|
14
|
-
export declare enum Namon {
|
|
15
|
-
PREFIX = "prefix",
|
|
16
|
-
LAST_NAME = "lastname",
|
|
17
|
-
MIDDLE_NAME = "middlename",
|
|
18
|
-
FIRST_NAME = "firstname",
|
|
19
|
-
SUFFIX = "suffix"
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Enum for the prefix values
|
|
23
|
-
* @readonly
|
|
24
|
-
* @enum {string}
|
|
25
|
-
* American and Canadian English follow slightly different rules for abbreviated
|
|
26
|
-
* titles than British and Australian English. In North American English, titles
|
|
27
|
-
* before a name require a period: `Mr., Mrs., Ms., Dr.` In British and Australian
|
|
28
|
-
* English, no full stops are used in these abbreviations.
|
|
29
|
-
*/
|
|
30
|
-
export declare enum Prefix {
|
|
31
|
-
FIRT_LIEUTENANT = "1st Lt",
|
|
32
|
-
ADMIRAL = "Adm",
|
|
33
|
-
ATTORNEY = "Atty",
|
|
34
|
-
BROTHER = "Brother",
|
|
35
|
-
CAPTAIN = "Capt",
|
|
36
|
-
CHIEF = "Chief",
|
|
37
|
-
COMMANDER = "Cmdr",
|
|
38
|
-
COLONEL = "Col",
|
|
39
|
-
UNI_DEAN = "Dean",
|
|
40
|
-
DOCTOR = "Dr",
|
|
41
|
-
ELDER = "Elder",
|
|
42
|
-
FATHER = "Father",
|
|
43
|
-
GENERAL = "Gen",
|
|
44
|
-
HONORABLE = "Hon",
|
|
45
|
-
LIEUTENANT_COLONEL = "Lt Col",
|
|
46
|
-
MAJOR = "Maj",
|
|
47
|
-
MASTER_SERGEANT = "MSgt",
|
|
48
|
-
MISTER = "Mr",
|
|
49
|
-
MARRIED_WOMAN = "Mrs",
|
|
50
|
-
SINGLE_WOMAN = "Ms",
|
|
51
|
-
PRINCE = "Prince",
|
|
52
|
-
PROFESSOR = "Prof",
|
|
53
|
-
RABBI = "Rabbi",
|
|
54
|
-
REVEREND = "Rev",
|
|
55
|
-
SISTER = "Sister"
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Enum for the suffix values
|
|
59
|
-
* @readonly
|
|
60
|
-
* @enum {string}
|
|
61
|
-
*/
|
|
62
|
-
export declare enum Suffix {
|
|
63
|
-
THE_SECOND = "II",
|
|
64
|
-
THE_THIRD = "III",
|
|
65
|
-
THE_FOURTH = "IV",
|
|
66
|
-
CERT_PUB_ACCOUNTANT = "CPA",
|
|
67
|
-
DOCTOR_DENTAL_MED = "DDS",
|
|
68
|
-
ESQUIRE = "Esq",
|
|
69
|
-
JURIST_DOCTOR = "JD",
|
|
70
|
-
JUNIOR = "Jr",
|
|
71
|
-
DOCTOR_OF_LAWS = "LLD",
|
|
72
|
-
DOCTORATE = "PhD",
|
|
73
|
-
RETIRED_ARMED_FORCES = "Ret",
|
|
74
|
-
REGISTERED_NURSE = "RN",
|
|
75
|
-
SENIOR = "Sr",
|
|
76
|
-
DOCTOR_OF_OSTEO = "DO"
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Enum for the separator values representing some of the ASCII characters
|
|
80
|
-
* @readonly
|
|
81
|
-
* @enum {string}
|
|
82
|
-
*/
|
|
83
|
-
export declare enum Separator {
|
|
84
|
-
COLON = ":",
|
|
85
|
-
COMMA = ",",
|
|
86
|
-
EMPTY = "",
|
|
87
|
-
HYPHEN = "-",
|
|
88
|
-
PERIOD = ".",
|
|
89
|
-
SPACE = " ",
|
|
90
|
-
UNDERSCORE = "_"
|
|
91
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* First name class definition
|
|
3
|
-
*
|
|
4
|
-
* Created on March 06, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
import { Name, Summary } from './index';
|
|
8
|
-
/**
|
|
9
|
-
* Represents a first name with some extra functionalities
|
|
10
|
-
* @class
|
|
11
|
-
* @extends Name
|
|
12
|
-
*/
|
|
13
|
-
export declare class Firstname extends Name {
|
|
14
|
-
namon: string;
|
|
15
|
-
more?: string[];
|
|
16
|
-
/**
|
|
17
|
-
* Constructs a `Firstname`
|
|
18
|
-
* @param {string} namon a piece of string that will be defined as a namon
|
|
19
|
-
* @param {string[]} [more] additional pieces considered as a given name
|
|
20
|
-
*/
|
|
21
|
-
constructor(namon: string, more?: string[]);
|
|
22
|
-
/**
|
|
23
|
-
* Gives some descriptive statistics that summarize the central tendency,
|
|
24
|
-
* dispersion and shape of the characters' distribution.
|
|
25
|
-
* @param {boolean} includeAll whether to include other pieces of the first
|
|
26
|
-
* name in the summary
|
|
27
|
-
* @see {@link describe} in `Namefully` class for further information
|
|
28
|
-
*/
|
|
29
|
-
describe(includeAll?: boolean): Summary;
|
|
30
|
-
/**
|
|
31
|
-
* Returns a string representation of the first name
|
|
32
|
-
* @param {boolean} includeAll whether to include other pieces of the first
|
|
33
|
-
* name
|
|
34
|
-
*/
|
|
35
|
-
tostring(includeAll?: boolean): string;
|
|
36
|
-
/**
|
|
37
|
-
* Gets the initials of the first name
|
|
38
|
-
* @returns {Array<string>} the initials
|
|
39
|
-
*/
|
|
40
|
-
getInitials(includeAll?: boolean): string[];
|
|
41
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Make all the locals available
|
|
3
|
-
*
|
|
4
|
-
* Created on March 06, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
export * from './name';
|
|
8
|
-
export * from './firstname';
|
|
9
|
-
export * from './lastname';
|
|
10
|
-
export * from './enums';
|
|
11
|
-
export * from './summary';
|
|
12
|
-
export * from './misc';
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Last name class definition
|
|
3
|
-
*
|
|
4
|
-
* Created on March 06, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
import { Name, Summary, LastnameFormat } from './index';
|
|
8
|
-
/**
|
|
9
|
-
* Represents a last name with some extra functionalities
|
|
10
|
-
* @class
|
|
11
|
-
* @extends Name
|
|
12
|
-
*/
|
|
13
|
-
export declare class Lastname extends Name {
|
|
14
|
-
father: string;
|
|
15
|
-
mother?: string;
|
|
16
|
-
private format;
|
|
17
|
-
/**
|
|
18
|
-
* Constructs a `Lastname`
|
|
19
|
-
* @param {string} father a piece of string that will be defined as a namon
|
|
20
|
-
* @param {string} [mother] additional pieces considered as a last name
|
|
21
|
-
* @param {LastnameFormat} [format] how to output a surname considering its
|
|
22
|
-
* subparts
|
|
23
|
-
*/
|
|
24
|
-
constructor(father: string, mother?: string, format?: LastnameFormat);
|
|
25
|
-
/**
|
|
26
|
-
* Gives some descriptive statistics that summarize the central tendency,
|
|
27
|
-
* dispersion and shape of the characters' distribution.
|
|
28
|
-
* @param {LastnameFormat} [format] overrides the how-to format of a surname
|
|
29
|
-
* output, considering its subparts.
|
|
30
|
-
* @see {@link describe} in `Namefully` class for further information
|
|
31
|
-
*/
|
|
32
|
-
describe(format?: LastnameFormat): Summary;
|
|
33
|
-
/**
|
|
34
|
-
* Returns a string representation of the last name
|
|
35
|
-
* @param {LastnameFormat} [format] overrides the how-to format of a surname
|
|
36
|
-
* output, considering its subparts.
|
|
37
|
-
*/
|
|
38
|
-
tostring(format?: LastnameFormat): string;
|
|
39
|
-
/**
|
|
40
|
-
* Gets the initials of the last name
|
|
41
|
-
* @returns {Array<string>} the initials
|
|
42
|
-
*/
|
|
43
|
-
getInitials(format?: LastnameFormat): string[];
|
|
44
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Miscellaneous contents
|
|
3
|
-
*
|
|
4
|
-
* Created on March 07, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
import { Parser } from '../core/index';
|
|
8
|
-
import { Name, Firstname, Lastname, Prefix, Suffix, Separator } from './index';
|
|
9
|
-
/**
|
|
10
|
-
* Interface for JSON signature that represents the full name
|
|
11
|
-
* @interface
|
|
12
|
-
*/
|
|
13
|
-
export interface Fullname {
|
|
14
|
-
firstname: Firstname;
|
|
15
|
-
lastname: Lastname;
|
|
16
|
-
middlename?: Name[];
|
|
17
|
-
prefix?: Prefix;
|
|
18
|
-
suffix?: Suffix;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Defines the two ways that a full name can be ordered: first or last name
|
|
22
|
-
* @typedef NameOrder
|
|
23
|
-
*/
|
|
24
|
-
export declare type NameOrder = 'firstname' | 'lastname';
|
|
25
|
-
/**
|
|
26
|
-
* Defines the distinct formats to output a surname
|
|
27
|
-
* @typedef LastnameFormat
|
|
28
|
-
*/
|
|
29
|
-
export declare type LastnameFormat = 'father' | 'mother' | 'hyphenated' | 'all';
|
|
30
|
-
/**
|
|
31
|
-
* Defines the ways the international community defines a title
|
|
32
|
-
*
|
|
33
|
-
* American and Canadian English follow slightly different rules for abbreviated
|
|
34
|
-
* titles than British and Australian English. In North American English, titles
|
|
35
|
-
* before a name require a period: `Mr., Mrs., Ms., Dr.` In British and Australian
|
|
36
|
-
* English, no full stops are used in these abbreviations.
|
|
37
|
-
* @typedef AbbrTitle
|
|
38
|
-
*/
|
|
39
|
-
export declare type AbbrTitle = 'us' | 'uk';
|
|
40
|
-
/**
|
|
41
|
-
* Interface for JSON signature that represents the configuration of the utility
|
|
42
|
-
* @interface
|
|
43
|
-
*/
|
|
44
|
-
export interface Config {
|
|
45
|
-
orderedBy: NameOrder;
|
|
46
|
-
separator: Separator;
|
|
47
|
-
titling: AbbrTitle;
|
|
48
|
-
ending: Separator;
|
|
49
|
-
bypass: boolean;
|
|
50
|
-
parser?: Parser<any>;
|
|
51
|
-
lastnameFormat?: LastnameFormat;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @interface Nama represents the JSON signature for the `NamaParser`
|
|
55
|
-
*/
|
|
56
|
-
export interface Nama {
|
|
57
|
-
prefix?: string;
|
|
58
|
-
firstname: string;
|
|
59
|
-
middlename?: string;
|
|
60
|
-
lastname: string;
|
|
61
|
-
suffix?: string;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* @interface Indexing represents the JSON signature for indexing name parts
|
|
65
|
-
*/
|
|
66
|
-
interface Indexing<T> {
|
|
67
|
-
prefix: T;
|
|
68
|
-
firstname: T;
|
|
69
|
-
middlename: T;
|
|
70
|
-
lastname: T;
|
|
71
|
-
suffix: T;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* @interface NameIndex represents the JSON signature for indexing name parts
|
|
75
|
-
* using numbered index
|
|
76
|
-
* @extends Index<number>
|
|
77
|
-
*/
|
|
78
|
-
export interface NameIndex extends Indexing<number> {
|
|
79
|
-
}
|
|
80
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Name class definition
|
|
3
|
-
*
|
|
4
|
-
* Created on March 06, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
import { Summary, Namon } from './index';
|
|
8
|
-
/**
|
|
9
|
-
* Represents a namon with some extra functionalities
|
|
10
|
-
* @class
|
|
11
|
-
* @see {@link Namon} interface to understand the concept of namon/nama.
|
|
12
|
-
*/
|
|
13
|
-
export declare class Name {
|
|
14
|
-
namon: string;
|
|
15
|
-
type: Namon;
|
|
16
|
-
private initial;
|
|
17
|
-
private body;
|
|
18
|
-
/**
|
|
19
|
-
* Constructs a `Name`
|
|
20
|
-
* @param namon a piece of string that will be defined as a namon
|
|
21
|
-
* @param type which namon that is
|
|
22
|
-
*/
|
|
23
|
-
constructor(namon: string, type: Namon, capitalized?: 'initial' | 'all');
|
|
24
|
-
/**
|
|
25
|
-
* Gives some descriptive statistics that summarize the central tendency,
|
|
26
|
-
* dispersion and shape of the characters' distribution.
|
|
27
|
-
* @see {@link describe} in `Namefully` class for further information
|
|
28
|
-
*/
|
|
29
|
-
describe(): Summary;
|
|
30
|
-
/**
|
|
31
|
-
* Gets the initials of the name
|
|
32
|
-
* @returns {Array<string>} the initials
|
|
33
|
-
*/
|
|
34
|
-
getInitials(): string[];
|
|
35
|
-
/**
|
|
36
|
-
* Capitalizes a name
|
|
37
|
-
* @param {'initial' | 'all'} option how to capitalize it
|
|
38
|
-
*/
|
|
39
|
-
protected capitalize(option?: 'initial' | 'all'): void;
|
|
40
|
-
/**
|
|
41
|
-
* Converts all the alphabetic characters in a string to lowercase
|
|
42
|
-
*/
|
|
43
|
-
lower(): string;
|
|
44
|
-
/**
|
|
45
|
-
* Converts all the alphabetic characters in a string to uppercase
|
|
46
|
-
*/
|
|
47
|
-
upper(): string;
|
|
48
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents the statistical summary of a string representation
|
|
3
|
-
* @class
|
|
4
|
-
*/
|
|
5
|
-
export declare class Summary {
|
|
6
|
-
private namon;
|
|
7
|
-
count: number;
|
|
8
|
-
frequency: number;
|
|
9
|
-
top: string;
|
|
10
|
-
unique: number;
|
|
11
|
-
/**
|
|
12
|
-
* Creates a `Summary` of a given string of alphabetical characters
|
|
13
|
-
* @param namon piece of name
|
|
14
|
-
* @param restrictions a set of undesired characters
|
|
15
|
-
*/
|
|
16
|
-
constructor(namon: string, restrictions?: string[]);
|
|
17
|
-
/**
|
|
18
|
-
* Returns a string representation of the summary
|
|
19
|
-
*/
|
|
20
|
-
tostring(): string;
|
|
21
|
-
private compute;
|
|
22
|
-
private groupByChar;
|
|
23
|
-
}
|
|
@@ -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,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,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,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,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,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
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `Fullname` validator
|
|
3
|
-
*
|
|
4
|
-
* Created on March 15, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
import { Fullname } from '../models/index';
|
|
8
|
-
import { Validator, ValidatorType } from './index';
|
|
9
|
-
/**
|
|
10
|
-
* Represents a `Fullname` (JSON signature) validator for provided custom parser
|
|
11
|
-
* @class
|
|
12
|
-
* @implements {Validator}
|
|
13
|
-
*/
|
|
14
|
-
export default class FullnameValidator implements Validator<Fullname> {
|
|
15
|
-
readonly type: ValidatorType;
|
|
16
|
-
/**
|
|
17
|
-
* Validates that the `Fullname` contract is met
|
|
18
|
-
* @param {Fullname} value data to validate
|
|
19
|
-
*/
|
|
20
|
-
validate(v: Fullname): void;
|
|
21
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Make all the locals available
|
|
3
|
-
*
|
|
4
|
-
* Created on March 06, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
export * from './common/validation-rule';
|
|
8
|
-
export * from './common/validation-type';
|
|
9
|
-
export * from './common/validation-error';
|
|
10
|
-
export * from './validator';
|
|
11
|
-
export { default as NamonValidator } from './namon.validator';
|
|
12
|
-
export { default as PrefixValidator } from './prefix.validator';
|
|
13
|
-
export { default as SuffixValidator } from './suffix.validator';
|
|
14
|
-
export { default as FirstnameValidator } from './firstname.validator';
|
|
15
|
-
export { default as LastnameValidator } from './lastname.validator';
|
|
16
|
-
export { default as MiddlenameValidator } from './middlename.validator';
|
|
17
|
-
export { default as FullnameValidator } from './fullname.validator';
|
|
18
|
-
export { default as NamaValidator } from './nama.validator';
|
|
19
|
-
export { default as ArrayNameValidator } from './array-name.validator';
|
|
20
|
-
export { default as ArrayStringValidator } from './array-string.validator';
|
|
21
|
-
export { default as StringNameValidator } from './string-name.validator';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Last 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 last name validator
|
|
10
|
-
* @class
|
|
11
|
-
* @implements {Validator}
|
|
12
|
-
*/
|
|
13
|
-
export default class LastnameValidator implements Validator<string> {
|
|
14
|
-
readonly type: ValidatorType;
|
|
15
|
-
/**
|
|
16
|
-
* Validates the content of a last name
|
|
17
|
-
* @param {string} value data to validate
|
|
18
|
-
*/
|
|
19
|
-
validate(value: string): void;
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Middle 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 middle name validator
|
|
10
|
-
* @class
|
|
11
|
-
* @implements {Validator}
|
|
12
|
-
*/
|
|
13
|
-
export default class MiddlenameValidator implements Validator<string | string[]> {
|
|
14
|
-
readonly type: ValidatorType;
|
|
15
|
-
/**
|
|
16
|
-
* Validates the content of a list of middle names
|
|
17
|
-
* @param {string | Array<string>} values to validate
|
|
18
|
-
*/
|
|
19
|
-
validate(values: string | string[]): void;
|
|
20
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Nama validator
|
|
3
|
-
*
|
|
4
|
-
* Created on March 15, 2020
|
|
5
|
-
* @author Ralph Florent <ralflornt@gmail.com>
|
|
6
|
-
*/
|
|
7
|
-
import { Nama } from '../models/index';
|
|
8
|
-
import { Validator, ValidatorType } from './index';
|
|
9
|
-
/**
|
|
10
|
-
* Represents a `Nama` validator to help the nama parser
|
|
11
|
-
* @class
|
|
12
|
-
* @implements {Validator}
|
|
13
|
-
*/
|
|
14
|
-
export default class NamaValidator implements Validator<Nama> {
|
|
15
|
-
readonly type: ValidatorType;
|
|
16
|
-
/**
|
|
17
|
-
* Validates the content of a JSON-formatted names
|
|
18
|
-
* @param {string} value data to validate
|
|
19
|
-
*/
|
|
20
|
-
validate(value: Nama): void;
|
|
21
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Namon 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 namon validator to help to parse single pieces of string
|
|
10
|
-
* @class
|
|
11
|
-
* @implements {Validator}
|
|
12
|
-
*/
|
|
13
|
-
export default class NamonValidator 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
|
-
}
|