@forwardslashns/taskit-validation-messages 1.10.43 → 1.10.44
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":"validation-message.formatter.d.ts","sourceRoot":"","sources":["../../src/validation/validation-message.formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAA+B,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"validation-message.formatter.d.ts","sourceRoot":"","sources":["../../src/validation/validation-message.formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAA+B,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAU7F,KAAK,QAAQ,GAAG,MAAM,OAAO,mBAAmB,CAAC;AACjD,KAAK,SAAS,CAAC,CAAC,SAAS,QAAQ,IAAI,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3E,KAAK,kBAAkB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;IAC/G,MAAM,EAAE,MAAM,CAAC,SAAS,SAAS,MAAM,EAAE,CAAC;CAC3C,GACG,CAAC,GACD,EAAE,CAAC;AACP,KAAK,aAAa,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,IAAI;KAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM;CAAE,CAAC;AAE/E,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,kBAAkB,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,WAAW,SAAS,QAAQ,EAAE,gBAAgB,SAAS,SAAS,CAAC,WAAW,CAAC,EAChH,aAAa,GAAG,WAAW,IAAI,gBAAgB,GAAG,MAAM,EAAE,EAC1D,SAAS,aAAa,CAAC,kBAAkB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC,KACxE,uBAqDF,CAAC"}
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getValidationMessage = void 0;
|
|
4
4
|
const validation_messages_1 = require("./validation-messages");
|
|
5
|
+
const escapeHtml = (text) => text
|
|
6
|
+
.replaceAll('&', '&')
|
|
7
|
+
.replaceAll('<', '<')
|
|
8
|
+
.replaceAll('>', '>')
|
|
9
|
+
.replaceAll('"', '"')
|
|
10
|
+
.replaceAll("'", ''');
|
|
5
11
|
const getValidationMessage = (combinedKey, params) => {
|
|
6
12
|
const parts = combinedKey.split('.');
|
|
7
13
|
const feature = parts[0];
|
|
@@ -36,7 +42,7 @@ const getValidationMessage = (combinedKey, params) => {
|
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
expectedParams.forEach((param) => {
|
|
39
|
-
message = message.replaceAll(`{${param}}`, inputParams[param]);
|
|
45
|
+
message = message.replaceAll(`{${param}}`, `<b>${escapeHtml(inputParams[param])}</b>`);
|
|
40
46
|
});
|
|
41
47
|
return {
|
|
42
48
|
content: message,
|
package/package.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { VALIDATION_MESSAGES } from './validation-messages';
|
|
2
2
|
import { ValidationMessageDefinition, ValidationSeverity } from './validation-message.types';
|
|
3
3
|
|
|
4
|
+
const escapeHtml = (text: string): string =>
|
|
5
|
+
text
|
|
6
|
+
.replaceAll('&', '&')
|
|
7
|
+
.replaceAll('<', '<')
|
|
8
|
+
.replaceAll('>', '>')
|
|
9
|
+
.replaceAll('"', '"')
|
|
10
|
+
.replaceAll("'", ''');
|
|
11
|
+
|
|
4
12
|
type Features = keyof typeof VALIDATION_MESSAGES;
|
|
5
13
|
type ErrorType<F extends Features> = keyof (typeof VALIDATION_MESSAGES)[F];
|
|
6
14
|
type ErrorMessageParams<F extends Features, E extends ErrorType<F>> = (typeof VALIDATION_MESSAGES)[F][E] extends {
|
|
@@ -64,7 +72,7 @@ export const getValidationMessage = <FeatureType extends Features, FeatureErrorT
|
|
|
64
72
|
}
|
|
65
73
|
|
|
66
74
|
expectedParams.forEach((param) => {
|
|
67
|
-
message = message.replaceAll(`{${param}}`, (inputParams as Record<string, string>)[param]);
|
|
75
|
+
message = message.replaceAll(`{${param}}`, `<b>${escapeHtml((inputParams as Record<string, string>)[param])}</b>`);
|
|
68
76
|
});
|
|
69
77
|
|
|
70
78
|
return {
|