@natrave/shared-entities 8.35.0 → 8.36.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promotion-creative.validation.d.ts","sourceRoot":"","sources":["../../../src/promotions/validation/promotion-creative.validation.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,sBAAsB;IAErC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,kBAAkB,CAAC;IAC/D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;
|
|
1
|
+
{"version":3,"file":"promotion-creative.validation.d.ts","sourceRoot":"","sources":["../../../src/promotions/validation/promotion-creative.validation.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,sBAAsB;IAErC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,kBAAkB,CAAC;IAC/D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAsDD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,gCAAgC,GACtC,sBAAsB,EAAE,CA+B1B;AAGD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,gCAAgC,GAAG,OAAO,CAExF"}
|
|
@@ -2,40 +2,34 @@ import { PromotionCreativeTemplate } from "../enums/promotion-creative-template.
|
|
|
2
2
|
const HEX_COLOR = /^#[0-9a-fA-F]{6}$/;
|
|
3
3
|
const HTTPS_URL = /^https:\/\/\S+$/;
|
|
4
4
|
const CONSENT_MAX_LENGTH = 280;
|
|
5
|
-
const
|
|
6
|
-
posterColor: {
|
|
7
|
-
required: true,
|
|
8
|
-
maxLength: 7,
|
|
9
|
-
pattern: HEX_COLOR,
|
|
10
|
-
patternMessage: "Use a cor no formato #RRGGBB."
|
|
11
|
-
},
|
|
12
|
-
monogram: { required: !hasImage, maxLength: 3 },
|
|
5
|
+
const TOURNAMENT_POSTER_RULES = {
|
|
13
6
|
posterImageUrl: {
|
|
14
|
-
required:
|
|
7
|
+
required: true,
|
|
15
8
|
maxLength: 2048,
|
|
16
9
|
pattern: HTTPS_URL,
|
|
17
10
|
patternMessage: "Use uma URL https."
|
|
18
11
|
},
|
|
12
|
+
posterColor: {
|
|
13
|
+
required: false,
|
|
14
|
+
maxLength: 7,
|
|
15
|
+
pattern: HEX_COLOR,
|
|
16
|
+
patternMessage: "Use a cor no formato #RRGGBB."
|
|
17
|
+
},
|
|
18
|
+
monogram: { required: false, maxLength: 3 },
|
|
19
19
|
headline: { required: false, maxLength: 80 },
|
|
20
20
|
kicker: { required: false, maxLength: 80 },
|
|
21
21
|
badge: { required: false, maxLength: 40 },
|
|
22
22
|
ctaLabel: { required: true, maxLength: 40 },
|
|
23
23
|
dismissLabel: { required: true, maxLength: 40 },
|
|
24
24
|
contactMessage: { required: false, maxLength: 500 }
|
|
25
|
-
}
|
|
25
|
+
};
|
|
26
26
|
const isFilled = (value) => typeof value === "string" && value.trim().length > 0;
|
|
27
27
|
function validatePromotionCreative(input) {
|
|
28
28
|
if (input.template !== PromotionCreativeTemplate.TOURNAMENT_POSTER) {
|
|
29
29
|
return [{ field: "template", code: "UNKNOWN_TEMPLATE", message: "Layout desconhecido." }];
|
|
30
30
|
}
|
|
31
31
|
const issues = [];
|
|
32
|
-
if (
|
|
33
|
-
issues.push({
|
|
34
|
-
field: "consentText",
|
|
35
|
-
code: "REQUIRED",
|
|
36
|
-
message: "Preencha o aviso de compartilhamento."
|
|
37
|
-
});
|
|
38
|
-
} else if (input.consentText.trim().length > CONSENT_MAX_LENGTH) {
|
|
32
|
+
if (isFilled(input.consentText) && input.consentText.trim().length > CONSENT_MAX_LENGTH) {
|
|
39
33
|
issues.push({
|
|
40
34
|
field: "consentText",
|
|
41
35
|
code: "TOO_LONG",
|
|
@@ -48,8 +42,7 @@ function validatePromotionCreative(input) {
|
|
|
48
42
|
return issues;
|
|
49
43
|
}
|
|
50
44
|
const fields = new Map(Object.entries(content));
|
|
51
|
-
const
|
|
52
|
-
for (const [name, rule] of Object.entries(rules)) {
|
|
45
|
+
for (const [name, rule] of Object.entries(TOURNAMENT_POSTER_RULES)) {
|
|
53
46
|
const issue = checkField(name, fields.get(name), rule);
|
|
54
47
|
if (issue) {
|
|
55
48
|
issues.push(issue);
|