starta.microservice 0.1.12419 → 0.1.12477

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.
@@ -0,0 +1,81 @@
1
+ import { LanguageEnum } from './TranslationHelper';
2
+ export declare const requiredType: (type?: object) => {
3
+ type: string;
4
+ validators: any[];
5
+ };
6
+ export declare const requiredLoginValidator: (minLength?: number, maxLength?: number) => {
7
+ type: string;
8
+ validators: any[];
9
+ };
10
+ export declare const isoDateTimeValidator: () => {
11
+ type: string;
12
+ regex: RegExp;
13
+ };
14
+ export declare const requiredIsoDateTimeValidator: () => {
15
+ type: string;
16
+ validators: any[];
17
+ };
18
+ export declare const isoDateValidator: () => {
19
+ type: string;
20
+ regex: RegExp;
21
+ };
22
+ export declare const requiredIsoDateValidator: () => {
23
+ type: string;
24
+ validators: any[];
25
+ };
26
+ export declare const translationsValidator: (languageValidator: (translationName: LanguageEnum | "default") => any, includeDefault?: boolean) => {
27
+ type: string;
28
+ rules: {
29
+ default: any;
30
+ "uk-ua": any;
31
+ "en-us": any;
32
+ "ru-ru": any;
33
+ "pl-pl": any;
34
+ "de-de": any;
35
+ };
36
+ };
37
+ export declare const arrayValidator: (itemRule: object) => {
38
+ type: string;
39
+ itemRule: object;
40
+ };
41
+ export declare const objectValidator: (rules?: object) => {
42
+ type: string;
43
+ rules: object;
44
+ };
45
+ export declare const oneOfValidators: (validators: Array<object>) => {
46
+ type: string;
47
+ validators: object[];
48
+ };
49
+ export declare const equalsToValidator: (value: any) => {
50
+ type: string;
51
+ to: any;
52
+ };
53
+ export declare const allValidators: (validators: Array<object>) => {
54
+ type: string;
55
+ validators: object[];
56
+ };
57
+ export declare const draftJsValidator: () => {
58
+ type: string;
59
+ rules: object;
60
+ };
61
+ export declare const minValueValidator: (min: number) => {
62
+ type: string;
63
+ min: number;
64
+ };
65
+ export declare const maxValueValidator: (max: number) => {
66
+ type: string;
67
+ max: number;
68
+ };
69
+ export declare const requiredLanguageValidator: () => {
70
+ type: string;
71
+ validators: ({
72
+ type: string;
73
+ validators?: undefined;
74
+ } | {
75
+ type: string;
76
+ validators: {
77
+ type: string;
78
+ to: any;
79
+ }[];
80
+ })[];
81
+ };
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requiredLanguageValidator = exports.maxValueValidator = exports.minValueValidator = exports.draftJsValidator = exports.allValidators = exports.equalsToValidator = exports.oneOfValidators = exports.objectValidator = exports.arrayValidator = exports.translationsValidator = exports.requiredIsoDateValidator = exports.isoDateValidator = exports.requiredIsoDateTimeValidator = exports.isoDateTimeValidator = exports.requiredLoginValidator = exports.requiredType = void 0;
4
+ const TranslationHelper_1 = require("./TranslationHelper");
5
+ const requiredType = (type = { type: 'string' }) => ({
6
+ type: 'all',
7
+ validators: [
8
+ { type: 'required' },
9
+ ...(Array.isArray(type) ? type : (type && [type]) || []),
10
+ ],
11
+ });
12
+ exports.requiredType = requiredType;
13
+ const requiredLoginValidator = (minLength = 3, maxLength = 24) => (0, exports.requiredType)({
14
+ type: 'regex',
15
+ regex: new RegExp(`[A-Za-z0-9_-]{${minLength},${maxLength}}$`),
16
+ });
17
+ exports.requiredLoginValidator = requiredLoginValidator;
18
+ const isoDateTimeValidator = () => ({
19
+ type: 'regex',
20
+ regex: /(\d{4})-(\d{2})-(\d{2})T((\d{2}):(\d{2}):(\d{2}))(\.\d{3})?Z$/i,
21
+ });
22
+ exports.isoDateTimeValidator = isoDateTimeValidator;
23
+ const requiredIsoDateTimeValidator = () => (0, exports.requiredType)((0, exports.isoDateTimeValidator)());
24
+ exports.requiredIsoDateTimeValidator = requiredIsoDateTimeValidator;
25
+ const isoDateValidator = () => ({
26
+ type: 'regex',
27
+ regex: /(\d{4})-(\d{2})-(\d{2})$/i,
28
+ });
29
+ exports.isoDateValidator = isoDateValidator;
30
+ const requiredIsoDateValidator = () => (0, exports.requiredType)((0, exports.isoDateValidator)());
31
+ exports.requiredIsoDateValidator = requiredIsoDateValidator;
32
+ const translationsValidator = (languageValidator, includeDefault = true) => ({
33
+ type: 'object',
34
+ rules: {
35
+ ...(includeDefault ? { default: languageValidator('default') } : {}),
36
+ ...TranslationHelper_1.SupportedLanguages.reduce((acc, lang) => {
37
+ acc[lang] = languageValidator(lang);
38
+ return acc;
39
+ }, {}),
40
+ },
41
+ });
42
+ exports.translationsValidator = translationsValidator;
43
+ const arrayValidator = (itemRule) => ({
44
+ type: 'array',
45
+ itemRule,
46
+ });
47
+ exports.arrayValidator = arrayValidator;
48
+ const objectValidator = (rules) => ({
49
+ type: 'object',
50
+ rules,
51
+ });
52
+ exports.objectValidator = objectValidator;
53
+ const oneOfValidators = (validators) => ({
54
+ type: 'oneOf',
55
+ validators,
56
+ });
57
+ exports.oneOfValidators = oneOfValidators;
58
+ const equalsToValidator = (value) => ({
59
+ type: 'equals',
60
+ to: value,
61
+ });
62
+ exports.equalsToValidator = equalsToValidator;
63
+ const allValidators = (validators) => ({
64
+ type: 'all',
65
+ validators,
66
+ });
67
+ exports.allValidators = allValidators;
68
+ const draftJsValidator = () => (0, exports.objectValidator)({
69
+ blocks: { type: 'required' },
70
+ entityMap: { type: 'required' },
71
+ });
72
+ exports.draftJsValidator = draftJsValidator;
73
+ const minValueValidator = (min) => ({
74
+ type: 'minValue',
75
+ min,
76
+ });
77
+ exports.minValueValidator = minValueValidator;
78
+ const maxValueValidator = (max) => ({
79
+ type: 'maxValue',
80
+ max,
81
+ });
82
+ exports.maxValueValidator = maxValueValidator;
83
+ const requiredLanguageValidator = () => ({
84
+ type: 'all',
85
+ validators: [
86
+ { type: 'required' },
87
+ {
88
+ type: 'oneOf',
89
+ validators: TranslationHelper_1.SupportedLanguages.map((lang) => (0, exports.equalsToValidator)(lang)),
90
+ },
91
+ ],
92
+ });
93
+ exports.requiredLanguageValidator = requiredLanguageValidator;
94
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src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AE,CACnC,IAAA,uBAAe,EAAC;IACd,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;IAC5B,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;CAChC,CAAC,CAAC;AAJQ,QAAA,gBAAgB,oBAIxB;AAEE,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC;IACjD,IAAI,EAAE,UAAU;IAChB,GAAG;CACJ,CAAC,CAAC;AAHU,QAAA,iBAAiB,qBAG3B;AAEI,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC;IACjD,IAAI,EAAE,UAAU;IAChB,GAAG;CACJ,CAAC,CAAC;AAHU,QAAA,iBAAiB,qBAG3B;AAEI,MAAM,yBAAyB,GAAG,GAAG,EAAE,CAAC,CAAC;IAC9C,IAAI,EAAE,KAAK;IACX,UAAU,EAAE;QACV,EAAE,IAAI,EAAE,UAAU,EAAE;QACpB;YACE,IAAI,EAAE,OAAO;YACb,UAAU,EAAE,sCAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,yBAAiB,EAAC,IAAI,CAAC,CAAC;SACtE;KACF;CACF,CAAC,CAAC;AATU,QAAA,yBAAyB,6BASnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starta.microservice",
3
- "version": "0.1.12419",
3
+ "version": "0.1.12477",
4
4
  "main": "./lib/index.js",
5
5
  "description": "Core library for Starta.one microservice",
6
6
  "author": "Collaboracia OÜ",