@platecms/delta-validation 0.4.1 → 0.7.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/package.json +5 -6
- package/src/lib/enums/rule-types.enum.ts +10 -0
- package/src/lib/errors/invalid-validation-arguments.error.ts +1 -0
- package/src/lib/errors/invalid-validation-rule-settings.error.ts +1 -0
- package/src/lib/errors/validation-error-details.ts +15 -0
- package/src/lib/errors/validation.error.ts +18 -0
- package/src/lib/helpers/deserialize-validation-rule.ts +94 -0
- package/src/lib/helpers/rule-to-schema.spec.ts +254 -0
- package/src/lib/helpers/rule-to-schema.ts +95 -0
- package/src/lib/helpers/schema-builder.spec.ts +52 -0
- package/src/lib/helpers/schema-builder.ts +28 -0
- package/src/lib/helpers/validate-with-function.spec.ts +264 -0
- package/src/lib/helpers/validate-with-function.ts +45 -0
- package/src/lib/schemas/array.schema.spec.ts +127 -0
- package/src/lib/schemas/array.schema.ts +104 -0
- package/src/lib/schemas/base.schema.spec.ts +168 -0
- package/src/lib/schemas/base.schema.ts +150 -0
- package/src/lib/schemas/content-value.schema.spec.ts +133 -0
- package/src/lib/schemas/content-value.schema.ts +61 -0
- package/src/lib/schemas/date.schema.spec.ts +144 -0
- package/src/lib/schemas/date.schema.ts +82 -0
- package/src/lib/schemas/number.schema.spec.ts +232 -0
- package/src/lib/schemas/number.schema.ts +123 -0
- package/src/lib/schemas/string.schema.spec.ts +135 -0
- package/src/lib/schemas/string.schema.ts +73 -0
- package/src/lib/test-utils/setup-files.ts +1 -0
- package/src/lib/test-utils/validation-result-matcher.ts +71 -0
- package/src/lib/types/{existing-content-validation-rules-settings.type.d.ts → existing-content-validation-rules-settings.type.ts} +10 -1
- package/src/lib/types/{existing-content-validation-rules.type.d.ts → existing-content-validation-rules.type.ts} +10 -1
- package/src/lib/types/{existing-validation-schemas.type.d.ts → existing-validation-schemas.type.ts} +7 -1
- package/src/lib/types/rule-instance.interface.ts +9 -0
- package/src/lib/types/{validation-context.interface.d.ts → validation-context.interface.ts} +3 -2
- package/src/lib/types/{validation-error-data.interface.d.ts → validation-error-data.interface.ts} +5 -4
- package/src/lib/types/{validation-result.interface.d.ts → validation-result.interface.ts} +3 -2
- package/src/lib/types/validation-schema.interface.ts +15 -0
- package/src/lib/validation-rules/allowed-values.validation-rule.spec.ts +57 -0
- package/src/lib/validation-rules/allowed-values.validation-rule.ts +53 -0
- package/src/lib/validation-rules/base.validation-rule.ts +35 -0
- package/src/lib/validation-rules/count.validation-rule.spec.ts +67 -0
- package/src/lib/validation-rules/count.validation-rule.ts +60 -0
- package/src/lib/validation-rules/date-between.validation-rule.spec.ts +77 -0
- package/src/lib/validation-rules/date-between.validation-rule.ts +54 -0
- package/src/lib/validation-rules/decimal-count.validation-rule.spec.ts +46 -0
- package/src/lib/validation-rules/decimal-count.validation-rule.ts +52 -0
- package/src/lib/validation-rules/number-between.validation-rule.spec.ts +77 -0
- package/src/lib/validation-rules/number-between.validation-rule.ts +58 -0
- package/src/lib/validation-rules/relatable-content-types.validation-rule.spec.ts +35 -0
- package/src/lib/validation-rules/relatable-content-types.validation-rule.ts +61 -0
- package/src/lib/validation-rules/string-format.validation-rule.spec.ts +43 -0
- package/src/lib/validation-rules/string-format.validation-rule.ts +50 -0
- package/src/lib/validation-rules/validation-rule-function.factory.ts +23 -0
- package/src/lib/validation-rules/value-type.validation-rule.spec.ts +108 -0
- package/src/lib/validation-rules/value-type.validation-rule.ts +76 -0
- package/src/index.js +0 -23
- package/src/index.js.map +0 -1
- package/src/lib/enums/rule-types.enum.d.ts +0 -10
- package/src/lib/enums/rule-types.enum.js +0 -15
- package/src/lib/enums/rule-types.enum.js.map +0 -1
- package/src/lib/errors/invalid-validation-arguments.error.d.ts +0 -2
- package/src/lib/errors/invalid-validation-arguments.error.js +0 -7
- package/src/lib/errors/invalid-validation-arguments.error.js.map +0 -1
- package/src/lib/errors/invalid-validation-rule-settings.error.d.ts +0 -2
- package/src/lib/errors/invalid-validation-rule-settings.error.js +0 -7
- package/src/lib/errors/invalid-validation-rule-settings.error.js.map +0 -1
- package/src/lib/errors/validation-error-details.d.ts +0 -6
- package/src/lib/errors/validation-error-details.js +0 -18
- package/src/lib/errors/validation-error-details.js.map +0 -1
- package/src/lib/errors/validation.error.d.ts +0 -8
- package/src/lib/errors/validation.error.js +0 -13
- package/src/lib/errors/validation.error.js.map +0 -1
- package/src/lib/helpers/deserialize-validation-rule.d.ts +0 -2
- package/src/lib/helpers/deserialize-validation-rule.js +0 -42
- package/src/lib/helpers/deserialize-validation-rule.js.map +0 -1
- package/src/lib/helpers/rule-to-schema.d.ts +0 -4
- package/src/lib/helpers/rule-to-schema.js +0 -65
- package/src/lib/helpers/rule-to-schema.js.map +0 -1
- package/src/lib/helpers/schema-builder.d.ts +0 -12
- package/src/lib/helpers/schema-builder.js +0 -27
- package/src/lib/helpers/schema-builder.js.map +0 -1
- package/src/lib/helpers/validate-with-function.d.ts +0 -4
- package/src/lib/helpers/validate-with-function.js +0 -31
- package/src/lib/helpers/validate-with-function.js.map +0 -1
- package/src/lib/schemas/array.schema.d.ts +0 -17
- package/src/lib/schemas/array.schema.js +0 -84
- package/src/lib/schemas/array.schema.js.map +0 -1
- package/src/lib/schemas/base.schema.d.ts +0 -20
- package/src/lib/schemas/base.schema.js +0 -95
- package/src/lib/schemas/base.schema.js.map +0 -1
- package/src/lib/schemas/content-value.schema.d.ts +0 -15
- package/src/lib/schemas/content-value.schema.js +0 -42
- package/src/lib/schemas/content-value.schema.js.map +0 -1
- package/src/lib/schemas/date.schema.d.ts +0 -13
- package/src/lib/schemas/date.schema.js +0 -62
- package/src/lib/schemas/date.schema.js.map +0 -1
- package/src/lib/schemas/number.schema.d.ts +0 -16
- package/src/lib/schemas/number.schema.js +0 -84
- package/src/lib/schemas/number.schema.js.map +0 -1
- package/src/lib/schemas/string.schema.d.ts +0 -11
- package/src/lib/schemas/string.schema.js +0 -56
- package/src/lib/schemas/string.schema.js.map +0 -1
- package/src/lib/types/existing-content-validation-rules-settings.type.js +0 -3
- package/src/lib/types/existing-content-validation-rules-settings.type.js.map +0 -1
- package/src/lib/types/existing-content-validation-rules.type.js +0 -3
- package/src/lib/types/existing-content-validation-rules.type.js.map +0 -1
- package/src/lib/types/existing-validation-schemas.type.js +0 -3
- package/src/lib/types/existing-validation-schemas.type.js.map +0 -1
- package/src/lib/types/rule-instance.interface.d.ts +0 -6
- package/src/lib/types/rule-instance.interface.js +0 -3
- package/src/lib/types/rule-instance.interface.js.map +0 -1
- package/src/lib/types/validation-context.interface.js +0 -3
- package/src/lib/types/validation-context.interface.js.map +0 -1
- package/src/lib/types/validation-error-data.interface.js +0 -3
- package/src/lib/types/validation-error-data.interface.js.map +0 -1
- package/src/lib/types/validation-result.interface.js +0 -3
- package/src/lib/types/validation-result.interface.js.map +0 -1
- package/src/lib/types/validation-schema.interface.d.ts +0 -7
- package/src/lib/types/validation-schema.interface.js +0 -3
- package/src/lib/types/validation-schema.interface.js.map +0 -1
- package/src/lib/validation-rules/allowed-values.validation-rule.d.ts +0 -13
- package/src/lib/validation-rules/allowed-values.validation-rule.js +0 -36
- package/src/lib/validation-rules/allowed-values.validation-rule.js.map +0 -1
- package/src/lib/validation-rules/base.validation-rule.d.ts +0 -13
- package/src/lib/validation-rules/base.validation-rule.js +0 -14
- package/src/lib/validation-rules/base.validation-rule.js.map +0 -1
- package/src/lib/validation-rules/count.validation-rule.d.ts +0 -16
- package/src/lib/validation-rules/count.validation-rule.js +0 -36
- package/src/lib/validation-rules/count.validation-rule.js.map +0 -1
- package/src/lib/validation-rules/date-between.validation-rule.d.ts +0 -16
- package/src/lib/validation-rules/date-between.validation-rule.js +0 -36
- package/src/lib/validation-rules/date-between.validation-rule.js.map +0 -1
- package/src/lib/validation-rules/decimal-count.validation-rule.d.ts +0 -13
- package/src/lib/validation-rules/decimal-count.validation-rule.js +0 -37
- package/src/lib/validation-rules/decimal-count.validation-rule.js.map +0 -1
- package/src/lib/validation-rules/number-between.validation-rule.d.ts +0 -16
- package/src/lib/validation-rules/number-between.validation-rule.js +0 -37
- package/src/lib/validation-rules/number-between.validation-rule.js.map +0 -1
- package/src/lib/validation-rules/relatable-content-types.validation-rule.d.ts +0 -13
- package/src/lib/validation-rules/relatable-content-types.validation-rule.js +0 -37
- package/src/lib/validation-rules/relatable-content-types.validation-rule.js.map +0 -1
- package/src/lib/validation-rules/string-format.validation-rule.d.ts +0 -13
- package/src/lib/validation-rules/string-format.validation-rule.js +0 -35
- package/src/lib/validation-rules/string-format.validation-rule.js.map +0 -1
- package/src/lib/validation-rules/validation-rule-function.factory.d.ts +0 -4
- package/src/lib/validation-rules/validation-rule-function.factory.js +0 -9
- package/src/lib/validation-rules/validation-rule-function.factory.js.map +0 -1
- package/src/lib/validation-rules/value-type.validation-rule.d.ts +0 -13
- package/src/lib/validation-rules/value-type.validation-rule.js +0 -53
- package/src/lib/validation-rules/value-type.validation-rule.js.map +0 -1
- /package/src/{index.d.ts → index.ts} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ContentValueType } from "@platecms/delta-types";
|
|
2
|
+
import { ValidationErrorDetails } from "../errors/validation-error-details";
|
|
3
|
+
import { RuleInstance } from "../types/rule-instance.interface";
|
|
4
|
+
import { RuleType } from "../enums/rule-types.enum";
|
|
5
|
+
import { BaseValidationRule, ContentValidationResultType } from "./base.validation-rule";
|
|
6
|
+
import { validationFunctionFromValidateValue } from "./validation-rule-function.factory";
|
|
7
|
+
|
|
8
|
+
function getDecimalCount(value: number): number {
|
|
9
|
+
const [_, decimalDigits] = value.toString().split(".");
|
|
10
|
+
return decimalDigits ? decimalDigits.length : 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function validateValueDecimalCount(
|
|
14
|
+
value: ContentValueType,
|
|
15
|
+
ruleInstance: RuleInstance<DecimalCountValidationRuleSettings>,
|
|
16
|
+
): ContentValidationResultType {
|
|
17
|
+
const num = Number(value);
|
|
18
|
+
if (Number.isNaN(num)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const decimalCount = getDecimalCount(num);
|
|
23
|
+
|
|
24
|
+
const maxDecimals = ruleInstance.settings.max;
|
|
25
|
+
const isDefined = maxDecimals != null && maxDecimals !== undefined;
|
|
26
|
+
if (isDefined && decimalCount > maxDecimals) {
|
|
27
|
+
return new ValidationErrorDetails(`The number must not have more than ${maxDecimals} decimals.`, ruleInstance);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
34
|
+
export const validateDecimalCount = validationFunctionFromValidateValue(validateValueDecimalCount);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A validation rule that checks whether the amount of decimals in a number is between a certain range.
|
|
38
|
+
* The amount of decimals is counted based on the amount of digits before the last
|
|
39
|
+
* non-zero digit after the decimal point.
|
|
40
|
+
* For example: 1.0000 has 0 decimals, 1.0001 has 4 decimals.
|
|
41
|
+
*/
|
|
42
|
+
export class DecimalCountValidationRule extends BaseValidationRule<DecimalCountValidationRuleSettings> {
|
|
43
|
+
public readonly ruleType: RuleType = RuleType.DECIMAL_COUNT;
|
|
44
|
+
|
|
45
|
+
public override validate(values: ContentValueType[]): ContentValidationResultType[] {
|
|
46
|
+
return validateDecimalCount(values, this);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface DecimalCountValidationRuleSettings {
|
|
51
|
+
max: number;
|
|
52
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { PRN } from "@platecms/delta-plate-resource-notation";
|
|
2
|
+
import { InvalidValidationRuleSettingsError } from "../errors/invalid-validation-rule-settings.error";
|
|
3
|
+
import { NumberBetweenValidationRule } from "./number-between.validation-rule";
|
|
4
|
+
|
|
5
|
+
describe("NumberBetweenValidationRule", () => {
|
|
6
|
+
const rulePrn = PRN.fromString("prn:plate:-1:cxc:validation-rule:1");
|
|
7
|
+
|
|
8
|
+
describe("constructor", () => {
|
|
9
|
+
it("throws an error if min and max are not provided", () => {
|
|
10
|
+
expect(() => {
|
|
11
|
+
new NumberBetweenValidationRule(rulePrn, {});
|
|
12
|
+
}).toThrowError(InvalidValidationRuleSettingsError);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe("validate", () => {
|
|
17
|
+
describe("with min and max", () => {
|
|
18
|
+
let rule: NumberBetweenValidationRule;
|
|
19
|
+
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
rule = new NumberBetweenValidationRule(rulePrn, {
|
|
22
|
+
min: 1,
|
|
23
|
+
max: 2,
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it.each([
|
|
28
|
+
[1, true],
|
|
29
|
+
[2, true],
|
|
30
|
+
[1.5, true],
|
|
31
|
+
[0.9, false],
|
|
32
|
+
[2.1, false],
|
|
33
|
+
["foo", null],
|
|
34
|
+
])("returns %s for value within the bounds", (value, expected) => {
|
|
35
|
+
expect(rule.validate([value])).toBeContentValidationResult([expected]);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe("with only min", () => {
|
|
40
|
+
let rule: NumberBetweenValidationRule;
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
rule = new NumberBetweenValidationRule(rulePrn, {
|
|
44
|
+
min: 1,
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it.each([
|
|
49
|
+
[1, true],
|
|
50
|
+
[1.1, true],
|
|
51
|
+
[0.9, false],
|
|
52
|
+
["foo", null],
|
|
53
|
+
])("returns %s for value within the bounds", (value, expected) => {
|
|
54
|
+
expect(rule.validate([value])).toBeContentValidationResult([expected]);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe("with only max", () => {
|
|
59
|
+
let rule: NumberBetweenValidationRule;
|
|
60
|
+
|
|
61
|
+
beforeEach(() => {
|
|
62
|
+
rule = new NumberBetweenValidationRule(rulePrn, {
|
|
63
|
+
max: 2,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it.each([
|
|
68
|
+
[2, true],
|
|
69
|
+
[1.9, true],
|
|
70
|
+
[2.1, false],
|
|
71
|
+
["foo", null],
|
|
72
|
+
])("returns %s for value within the bounds", (value, expected) => {
|
|
73
|
+
expect(rule.validate([value])).toBeContentValidationResult([expected]);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { PRN } from "@platecms/delta-plate-resource-notation";
|
|
2
|
+
import { ContentValueType } from "@platecms/delta-types";
|
|
3
|
+
import { InvalidValidationRuleSettingsError } from "../errors/invalid-validation-rule-settings.error";
|
|
4
|
+
import { ValidationErrorDetails } from "../errors/validation-error-details";
|
|
5
|
+
import { RuleInstance } from "../types/rule-instance.interface";
|
|
6
|
+
import { RuleType } from "../enums/rule-types.enum";
|
|
7
|
+
import { BaseValidationRule, ContentValidationResultType } from "./base.validation-rule";
|
|
8
|
+
import { validationFunctionFromValidateValue } from "./validation-rule-function.factory";
|
|
9
|
+
|
|
10
|
+
export function validateValueNumberBetween(
|
|
11
|
+
value: ContentValueType,
|
|
12
|
+
ruleInstance: RuleInstance<NumberBetweenValidationRuleSettings>,
|
|
13
|
+
): ContentValidationResultType {
|
|
14
|
+
const num = Number(value);
|
|
15
|
+
if (Number.isNaN(num)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (ruleInstance.settings.min != null && num < ruleInstance.settings.min) {
|
|
20
|
+
return new ValidationErrorDetails(
|
|
21
|
+
`The value must be greater than or equal ${ruleInstance.settings.min}.`,
|
|
22
|
+
ruleInstance,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
if (ruleInstance.settings.max != null && num > ruleInstance.settings.max) {
|
|
26
|
+
return new ValidationErrorDetails(
|
|
27
|
+
`The value must be less than or equal ${ruleInstance.settings.max}.`,
|
|
28
|
+
ruleInstance,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
35
|
+
export const validateNumberBetween = validationFunctionFromValidateValue(validateValueNumberBetween);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A validation rule that checks whether a number is between a certain range.
|
|
39
|
+
*/
|
|
40
|
+
export class NumberBetweenValidationRule extends BaseValidationRule<NumberBetweenValidationRuleSettings> {
|
|
41
|
+
public readonly ruleType: RuleType = RuleType.NUMBER_BETWEEN;
|
|
42
|
+
|
|
43
|
+
public constructor(prn: PRN, settings: NumberBetweenValidationRuleSettings) {
|
|
44
|
+
if (settings.min == null && settings.max == null) {
|
|
45
|
+
throw new InvalidValidationRuleSettingsError("Either min or max must be defined.");
|
|
46
|
+
}
|
|
47
|
+
super(prn, settings);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public override validate(values: ContentValueType[]): ContentValidationResultType[] {
|
|
51
|
+
return validateNumberBetween(values, this);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface NumberBetweenValidationRuleSettings {
|
|
56
|
+
min?: number;
|
|
57
|
+
max?: number;
|
|
58
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PRN } from "@platecms/delta-plate-resource-notation";
|
|
2
|
+
import { InvalidValidationArgumentsError } from "../errors/invalid-validation-arguments.error";
|
|
3
|
+
import { RelatableContentTypesValidationRule } from "./relatable-content-types.validation-rule";
|
|
4
|
+
|
|
5
|
+
describe("RelatableContentTypesValidationRule", () => {
|
|
6
|
+
const rulePrn = PRN.fromString("prn:plate:-1:cxc:validation-rule:1");
|
|
7
|
+
const contentItemPrn = PRN.fromString("prn:plate:-1:cxc:content-item:1");
|
|
8
|
+
|
|
9
|
+
const allowedContentTypes = [
|
|
10
|
+
PRN.fromString("prn:plate:-1:cxc:content-type:1"),
|
|
11
|
+
PRN.fromString("prn:plate:-1:cxc:content-type:2"),
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
const disallowedContentType = PRN.fromString("prn:plate:-1:cxc:content-type:3");
|
|
15
|
+
|
|
16
|
+
let rule: RelatableContentTypesValidationRule;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
rule = new RelatableContentTypesValidationRule(rulePrn, {
|
|
20
|
+
allowedContentTypes,
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it.each([
|
|
25
|
+
[contentItemPrn, allowedContentTypes[0], true],
|
|
26
|
+
[contentItemPrn, disallowedContentType, false],
|
|
27
|
+
["not a ContentItem", disallowedContentType, false],
|
|
28
|
+
])("returns %s for the provided content item", (contentItem, contentType, expected) => {
|
|
29
|
+
expect(rule.validate([contentItem], [contentType])).toBeContentValidationResult([expected]);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("throws an error if the value does not have a ContentType", () => {
|
|
33
|
+
expect(() => rule.validate([contentItemPrn])).toThrowError(InvalidValidationArgumentsError);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { PRN } from "@platecms/delta-plate-resource-notation";
|
|
2
|
+
import { ContentValueType } from "@platecms/delta-types";
|
|
3
|
+
import { InvalidValidationArgumentsError } from "../errors/invalid-validation-arguments.error";
|
|
4
|
+
import { ValidationErrorDetails } from "../errors/validation-error-details";
|
|
5
|
+
import { RuleInstance } from "../types/rule-instance.interface";
|
|
6
|
+
import { RuleType } from "../enums/rule-types.enum";
|
|
7
|
+
import { BaseValidationRule, ContentValidationResultType } from "./base.validation-rule";
|
|
8
|
+
|
|
9
|
+
function validateValueRelatableContentTypes<TContentType>(
|
|
10
|
+
value: ContentValueType,
|
|
11
|
+
contentType: TContentType,
|
|
12
|
+
ruleInstance: RuleInstance<RelatableContentTypesValidationRuleSettings<TContentType>>,
|
|
13
|
+
): ContentValidationResultType {
|
|
14
|
+
if (contentType === undefined) {
|
|
15
|
+
throw new InvalidValidationArgumentsError(`Missing attribute 'contentType' for value: ${JSON.stringify(value)}`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!ruleInstance.settings.allowedContentTypes.includes(contentType)) {
|
|
19
|
+
return new ValidationErrorDetails(
|
|
20
|
+
`The provided content type must be type of ${ruleInstance.settings.allowedContentTypes.join(", ")}`,
|
|
21
|
+
ruleInstance,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function validateRelatableContentTypes<TContentType>(
|
|
29
|
+
values: ContentValueType[],
|
|
30
|
+
ruleInstance: RuleInstance<RelatableContentTypesValidationRuleSettings<TContentType>>,
|
|
31
|
+
contentTypes: TContentType[],
|
|
32
|
+
): ContentValidationResultType[] {
|
|
33
|
+
if (values.length !== contentTypes.length) {
|
|
34
|
+
throw new InvalidValidationArgumentsError(`The length of values and contentTypes must be equal.`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return values.map((value, index) => validateValueRelatableContentTypes(value, contentTypes[index], ruleInstance));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A validation rule that checks whether a value (ContentItem) is of a certain ContentType
|
|
42
|
+
*/
|
|
43
|
+
export class RelatableContentTypesValidationRule extends BaseValidationRule<
|
|
44
|
+
RelatableContentTypesValidationRuleSettings<PRN>
|
|
45
|
+
> {
|
|
46
|
+
public readonly ruleType: RuleType = RuleType.RELATABLE_CONTENT_TYPES;
|
|
47
|
+
|
|
48
|
+
public override validate(values: ContentValueType[], contentTypes?: PRN[]): ContentValidationResultType[] {
|
|
49
|
+
if (contentTypes === undefined) {
|
|
50
|
+
throw new InvalidValidationArgumentsError(
|
|
51
|
+
`Missing attribute 'contentTypes' in values: ${JSON.stringify(values)}`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return validateRelatableContentTypes(values, this, contentTypes);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface RelatableContentTypesValidationRuleSettings<TContentType> {
|
|
60
|
+
allowedContentTypes: TContentType[];
|
|
61
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PRN } from "@platecms/delta-plate-resource-notation";
|
|
2
|
+
import { StringFormatValidationRule } from "./string-format.validation-rule";
|
|
3
|
+
|
|
4
|
+
describe("StringFormatValidationRule", () => {
|
|
5
|
+
const rulePrn = PRN.fromString("prn:plate:-1:cxc:validation-rule:string-format");
|
|
6
|
+
|
|
7
|
+
describe("with an email regex", () => {
|
|
8
|
+
let rule: StringFormatValidationRule;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
rule = new StringFormatValidationRule(rulePrn, {
|
|
12
|
+
allowedFormat: "^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$",
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it.each([
|
|
17
|
+
["david@getplate.com", true],
|
|
18
|
+
["david@getplate", false],
|
|
19
|
+
[123, null],
|
|
20
|
+
])("returns %s for the provided value", (value, expected) => {
|
|
21
|
+
expect(rule.validate([value])).toBeContentValidationResult([expected]);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe("with a just letters regex", () => {
|
|
26
|
+
let rule: StringFormatValidationRule;
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
rule = new StringFormatValidationRule(rulePrn, {
|
|
30
|
+
allowedFormat: "^[a-zA-Z]+$",
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it.each([
|
|
35
|
+
["abc", true],
|
|
36
|
+
["abc123", false],
|
|
37
|
+
["", false],
|
|
38
|
+
[123, null],
|
|
39
|
+
])("returns %s for the provided value", (value, expected) => {
|
|
40
|
+
expect(rule.validate([value])).toBeContentValidationResult([expected]);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ContentValueType } from "@platecms/delta-types";
|
|
2
|
+
import { ValidationErrorDetails } from "../errors/validation-error-details";
|
|
3
|
+
import { RuleInstance } from "../types/rule-instance.interface";
|
|
4
|
+
import { RuleType } from "../enums/rule-types.enum";
|
|
5
|
+
import { BaseValidationRule, ContentValidationResultType } from "./base.validation-rule";
|
|
6
|
+
import { validationFunctionFromValidateValue } from "./validation-rule-function.factory";
|
|
7
|
+
|
|
8
|
+
export function validateValueStringFormat(
|
|
9
|
+
value: ContentValueType,
|
|
10
|
+
ruleInstance: RuleInstance<StringFormatValidationRuleSettings>,
|
|
11
|
+
): ContentValidationResultType {
|
|
12
|
+
if (typeof value !== "string") {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { allowedFormat } = ruleInstance.settings;
|
|
17
|
+
const isDefined = allowedFormat !== undefined && allowedFormat !== null;
|
|
18
|
+
|
|
19
|
+
if (!isDefined) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
24
|
+
const regex = new RegExp(allowedFormat);
|
|
25
|
+
|
|
26
|
+
if (!regex.test(value)) {
|
|
27
|
+
/* @TODO Determine how to display regex error to display what exactly went wrong */
|
|
28
|
+
return new ValidationErrorDetails(`String does not match the required format`, ruleInstance);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
35
|
+
export const validateStringFormat = validationFunctionFromValidateValue(validateValueStringFormat);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A validation rule that checks whether a string matches a certain format.
|
|
39
|
+
*/
|
|
40
|
+
export class StringFormatValidationRule extends BaseValidationRule<StringFormatValidationRuleSettings> {
|
|
41
|
+
public readonly ruleType: RuleType = RuleType.STRING_FORMAT;
|
|
42
|
+
|
|
43
|
+
public override validate(values: ContentValueType[]): ContentValidationResultType[] {
|
|
44
|
+
return validateStringFormat(values, this);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface StringFormatValidationRuleSettings {
|
|
49
|
+
allowedFormat: string;
|
|
50
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ContentValueType } from "@platecms/delta-types";
|
|
2
|
+
import { RuleInstance } from "../types/rule-instance.interface";
|
|
3
|
+
import { ContentValidationResultType } from "./base.validation-rule";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generates a function that validates ContentValue[] against the rule.
|
|
7
|
+
* The returned function returns array with for each value: true if the value is valid,
|
|
8
|
+
* ContentValidationErrorDetail if it is invalid, and null if the rule does not apply to the value.
|
|
9
|
+
* Some validation rules perform validation on the array as a whole, in which case the array will be validated as a whole,
|
|
10
|
+
* and the result will be returned in the first element of the array. E.g. the CountValidationRule.
|
|
11
|
+
*/
|
|
12
|
+
export function validationFunctionFromValidateValue<TRuleInstanceSettings>(
|
|
13
|
+
validateValue: (
|
|
14
|
+
value: ContentValueType,
|
|
15
|
+
ruleInstance: RuleInstance<TRuleInstanceSettings>,
|
|
16
|
+
) => ContentValidationResultType,
|
|
17
|
+
) {
|
|
18
|
+
return function validate<
|
|
19
|
+
TRuleInstance extends RuleInstance<TRuleInstanceSettings> = RuleInstance<TRuleInstanceSettings>,
|
|
20
|
+
>(values: ContentValueType[], ruleInstance: TRuleInstance): ContentValidationResultType[] {
|
|
21
|
+
return values.map((value) => validateValue(value, ruleInstance));
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { PRN } from "@platecms/delta-plate-resource-notation";
|
|
2
|
+
import { ContentValueType, ContentValueTypeNames } from "@platecms/delta-types";
|
|
3
|
+
import { ValueTypeValidationRule, ValueTypeValidationRuleSettings } from "./value-type.validation-rule";
|
|
4
|
+
|
|
5
|
+
describe("ValueTypeValidationRule", () => {
|
|
6
|
+
const rulePrn = PRN.fromString("prn:plate:-1:cxc:validation-rule:value-type");
|
|
7
|
+
|
|
8
|
+
describe.each([
|
|
9
|
+
[
|
|
10
|
+
"with allowed string type",
|
|
11
|
+
{ allowedTypes: [ContentValueTypeNames.STRING] },
|
|
12
|
+
[
|
|
13
|
+
["foo", true],
|
|
14
|
+
[123, false],
|
|
15
|
+
],
|
|
16
|
+
],
|
|
17
|
+
[
|
|
18
|
+
"with allowed number type",
|
|
19
|
+
{ allowedTypes: [ContentValueTypeNames.NUMBER] },
|
|
20
|
+
[
|
|
21
|
+
[123, true],
|
|
22
|
+
["foo", false],
|
|
23
|
+
],
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
"with allowed boolean type",
|
|
27
|
+
{ allowedTypes: [ContentValueTypeNames.BOOLEAN] },
|
|
28
|
+
[
|
|
29
|
+
[true, true],
|
|
30
|
+
["foo", false],
|
|
31
|
+
],
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
"with allowed date type",
|
|
35
|
+
{ allowedTypes: [ContentValueTypeNames.DATE] },
|
|
36
|
+
[
|
|
37
|
+
[new Date(), true],
|
|
38
|
+
["foo", false],
|
|
39
|
+
],
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
"with allowed content item type",
|
|
43
|
+
{ allowedTypes: [ContentValueTypeNames.CONTENT_ITEM] },
|
|
44
|
+
[
|
|
45
|
+
[PRN.fromString("prn:plate:-1:cxc:content-item:1"), true],
|
|
46
|
+
["foo", false],
|
|
47
|
+
],
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
"with allowed asset type",
|
|
51
|
+
{ allowedTypes: [ContentValueTypeNames.ASSET] },
|
|
52
|
+
[
|
|
53
|
+
[PRN.fromString("prn:plate:-1:am:asset:1"), true],
|
|
54
|
+
["foo", false],
|
|
55
|
+
],
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
"with allowed path part type",
|
|
59
|
+
{ allowedTypes: [ContentValueTypeNames.PATH_PART] },
|
|
60
|
+
[
|
|
61
|
+
[PRN.fromString("prn:plate:-1:cxc:path-part:1"), true],
|
|
62
|
+
["foo", false],
|
|
63
|
+
],
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
"with allowed grid placement type",
|
|
67
|
+
{ allowedTypes: [ContentValueTypeNames.GRID_PLACEMENT] },
|
|
68
|
+
[
|
|
69
|
+
[PRN.fromString("prn:plate:-1:cxc:grid-placement:1"), true],
|
|
70
|
+
["foo", false],
|
|
71
|
+
],
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
"with allowed smart text type",
|
|
75
|
+
{ allowedTypes: [ContentValueTypeNames.SMART_TEXT] },
|
|
76
|
+
[
|
|
77
|
+
[{ type: "root", children: [] }, true],
|
|
78
|
+
[PRN.fromString("prn:plate:-1:cxc:grid-placement:1"), false],
|
|
79
|
+
],
|
|
80
|
+
],
|
|
81
|
+
[
|
|
82
|
+
"with incorrect prn",
|
|
83
|
+
{ allowedTypes: [ContentValueTypeNames.CONTENT_ITEM] },
|
|
84
|
+
[[PRN.fromString("prn:plate:-1:am:asset:1"), false]],
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
"with multiple types",
|
|
88
|
+
{
|
|
89
|
+
allowedTypes: [ContentValueTypeNames.STRING, ContentValueTypeNames.CONTENT_ITEM],
|
|
90
|
+
},
|
|
91
|
+
[
|
|
92
|
+
["foo", true],
|
|
93
|
+
[PRN.fromString("prn:plate:-1:cxc:content-item:1"), true],
|
|
94
|
+
[new Date(), false],
|
|
95
|
+
],
|
|
96
|
+
],
|
|
97
|
+
])("%s", (_, ruleConfig, testCases: unknown[]) => {
|
|
98
|
+
let rule: ValueTypeValidationRule;
|
|
99
|
+
|
|
100
|
+
beforeEach(() => {
|
|
101
|
+
rule = new ValueTypeValidationRule(rulePrn, ruleConfig as ValueTypeValidationRuleSettings);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it.each(testCases)("returns %s for the provided value", (value, expected) => {
|
|
105
|
+
expect(rule.validate([value as ContentValueType])).toBeContentValidationResult([expected]);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { InvalidCastError, validateCast } from "@platecms/delta-cast";
|
|
2
|
+
import { PRN } from "@platecms/delta-plate-resource-notation";
|
|
3
|
+
import { ContentValueType, ContentValueTypeName, ContentValueTypeNames } from "@platecms/delta-types";
|
|
4
|
+
import { ValidationErrorDetails } from "../errors/validation-error-details";
|
|
5
|
+
import { RuleInstance } from "../types/rule-instance.interface";
|
|
6
|
+
import { RuleType } from "../enums/rule-types.enum";
|
|
7
|
+
import { BaseValidationRule, ContentValidationResultType } from "./base.validation-rule";
|
|
8
|
+
import { validationFunctionFromValidateValue } from "./validation-rule-function.factory";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Mapping of PRN resource type to Content Value Type Name.
|
|
12
|
+
*/
|
|
13
|
+
const prnResourceTypeToContentValueTypeNameMap: Record<string, ContentValueTypeNames> = {
|
|
14
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
15
|
+
"content-item": ContentValueTypeNames.CONTENT_ITEM,
|
|
16
|
+
asset: ContentValueTypeNames.ASSET,
|
|
17
|
+
"path-part": ContentValueTypeNames.PATH_PART,
|
|
18
|
+
"grid-placement": ContentValueTypeNames.GRID_PLACEMENT,
|
|
19
|
+
tag: ContentValueTypeNames.TAG,
|
|
20
|
+
"content-type": ContentValueTypeNames.CONTENT_TYPE,
|
|
21
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function validateValueValueType(
|
|
25
|
+
value: ContentValueType,
|
|
26
|
+
ruleInstance: RuleInstance<ValueTypeValidationRuleSettings>,
|
|
27
|
+
): ContentValidationResultType {
|
|
28
|
+
if (value instanceof Date && ruleInstance.settings.allowedTypes.includes(ContentValueTypeNames.DATE)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
validateCast(value);
|
|
34
|
+
if (ruleInstance.settings.allowedTypes.includes(ContentValueTypeNames.SMART_TEXT)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (!(error instanceof InvalidCastError)) {
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (
|
|
44
|
+
value instanceof PRN &&
|
|
45
|
+
ruleInstance.settings.allowedTypes.includes(prnResourceTypeToContentValueTypeNameMap[value.resourceType])
|
|
46
|
+
) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (
|
|
51
|
+
ruleInstance.settings.allowedTypes.includes((typeof value).toUpperCase() as ContentValueTypeName<ContentValueType>)
|
|
52
|
+
) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return new ValidationErrorDetails(`The value must be of the correct type.`, ruleInstance);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
60
|
+
export const validateValueType = validationFunctionFromValidateValue(validateValueValueType);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* A validation rule that checks whether a value is of a certain ContentValueType
|
|
64
|
+
*/
|
|
65
|
+
export class ValueTypeValidationRule extends BaseValidationRule<ValueTypeValidationRuleSettings> {
|
|
66
|
+
public readonly ruleType: RuleType = RuleType.VALUE_TYPE;
|
|
67
|
+
|
|
68
|
+
public override validate(values: ContentValueType[]): ContentValidationResultType[] {
|
|
69
|
+
return validateValueType(values, this);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// The value type can be one or more of the types specified in the ContentValueType type
|
|
74
|
+
export interface ValueTypeValidationRuleSettings {
|
|
75
|
+
allowedTypes: ContentValueTypeName<ContentValueType>[];
|
|
76
|
+
}
|
package/src/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./lib/errors/invalid-validation-arguments.error"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./lib/errors/invalid-validation-rule-settings.error"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./lib/errors/validation.error"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./lib/errors/validation-error-details"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./lib/helpers/deserialize-validation-rule"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./lib/validation-rules/number-between.validation-rule"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./lib/helpers/rule-to-schema"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./lib/helpers/schema-builder"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./lib/enums/rule-types.enum"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./lib/validation-rules/allowed-values.validation-rule"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./lib/validation-rules/base.validation-rule"), exports);
|
|
15
|
-
tslib_1.__exportStar(require("./lib/validation-rules/count.validation-rule"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./lib/validation-rules/date-between.validation-rule"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./lib/validation-rules/decimal-count.validation-rule"), exports);
|
|
18
|
-
tslib_1.__exportStar(require("./lib/validation-rules/number-between.validation-rule"), exports);
|
|
19
|
-
tslib_1.__exportStar(require("./lib/validation-rules/relatable-content-types.validation-rule"), exports);
|
|
20
|
-
tslib_1.__exportStar(require("./lib/validation-rules/string-format.validation-rule"), exports);
|
|
21
|
-
tslib_1.__exportStar(require("./lib/validation-rules/validation-rule-function.factory"), exports);
|
|
22
|
-
tslib_1.__exportStar(require("./lib/validation-rules/value-type.validation-rule"), exports);
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/validation/src/index.ts"],"names":[],"mappings":";;;AAAA,0FAAgE;AAChE,8FAAoE;AACpE,wEAA8C;AAC9C,gFAAsD;AACtD,oFAA0D;AAC1D,gGAAsE;AAEtE,uEAA6C;AAC7C,uEAA6C;AAM7C,sEAA4C;AAE5C,gGAAsE;AACtE,sFAA4D;AAC5D,uFAA6D;AAC7D,8FAAoE;AACpE,+FAAqE;AACrE,gGAAsE;AACtE,yGAA+E;AAC/E,+FAAqE;AACrE,kGAAwE;AACxE,4FAAkE"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare enum RuleType {
|
|
2
|
-
ALLOWED_VALUES = "ALLOWED_VALUES",
|
|
3
|
-
COUNT = "COUNT",
|
|
4
|
-
DATE_BETWEEN = "DATE_BETWEEN",
|
|
5
|
-
DECIMAL_COUNT = "DECIMAL_COUNT",
|
|
6
|
-
NUMBER_BETWEEN = "NUMBER_BETWEEN",
|
|
7
|
-
RELATABLE_CONTENT_TYPES = "RELATABLE_CONTENT_TYPES",
|
|
8
|
-
STRING_FORMAT = "STRING_FORMAT",
|
|
9
|
-
VALUE_TYPE = "VALUE_TYPE"
|
|
10
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RuleType = void 0;
|
|
4
|
-
var RuleType;
|
|
5
|
-
(function (RuleType) {
|
|
6
|
-
RuleType["ALLOWED_VALUES"] = "ALLOWED_VALUES";
|
|
7
|
-
RuleType["COUNT"] = "COUNT";
|
|
8
|
-
RuleType["DATE_BETWEEN"] = "DATE_BETWEEN";
|
|
9
|
-
RuleType["DECIMAL_COUNT"] = "DECIMAL_COUNT";
|
|
10
|
-
RuleType["NUMBER_BETWEEN"] = "NUMBER_BETWEEN";
|
|
11
|
-
RuleType["RELATABLE_CONTENT_TYPES"] = "RELATABLE_CONTENT_TYPES";
|
|
12
|
-
RuleType["STRING_FORMAT"] = "STRING_FORMAT";
|
|
13
|
-
RuleType["VALUE_TYPE"] = "VALUE_TYPE";
|
|
14
|
-
})(RuleType || (exports.RuleType = RuleType = {}));
|
|
15
|
-
//# sourceMappingURL=rule-types.enum.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rule-types.enum.js","sourceRoot":"","sources":["../../../../../../../packages/validation/src/lib/enums/rule-types.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,QASX;AATD,WAAY,QAAQ;IAClB,6CAAiC,CAAA;IACjC,2BAAe,CAAA;IACf,yCAA6B,CAAA;IAC7B,2CAA+B,CAAA;IAC/B,6CAAiC,CAAA;IACjC,+DAAmD,CAAA;IACnD,2CAA+B,CAAA;IAC/B,qCAAyB,CAAA;AAC3B,CAAC,EATW,QAAQ,wBAAR,QAAQ,QASnB"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidValidationArgumentsError = void 0;
|
|
4
|
-
class InvalidValidationArgumentsError extends Error {
|
|
5
|
-
}
|
|
6
|
-
exports.InvalidValidationArgumentsError = InvalidValidationArgumentsError;
|
|
7
|
-
//# sourceMappingURL=invalid-validation-arguments.error.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-validation-arguments.error.js","sourceRoot":"","sources":["../../../../../../../packages/validation/src/lib/errors/invalid-validation-arguments.error.ts"],"names":[],"mappings":";;;AAAA,MAAa,+BAAgC,SAAQ,KAAK;CAAG;AAA7D,0EAA6D"}
|