Skip to content

Commit 485df38

Browse files
committed
fix: show special characters properly in validation messages
Signed-off-by: romanetar <roman_ag@hotmail.com>
1 parent 757e964 commit 485df38

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

resources/js/utils.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,10 @@ export const formatTime = (timeInSeconds) => {
8080
res = res.slice(0, -2);
8181
}
8282
return res;
83-
}
83+
}
84+
85+
export const decodeHtmlEntities = (text) => {
86+
const textarea = document.createElement('textarea');
87+
textarea.innerHTML = text;
88+
return textarea.value;
89+
};

resources/js/validator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {ref, string} from "yup";
2+
import {decodeHtmlEntities} from "./utils.js"
23

34
const validatePasswordPattern = (shapePattern, allowed_special_characters, warning) => {
45
return function(value) {
@@ -25,7 +26,7 @@ const validatePasswordPattern = (shapePattern, allowed_special_characters, warni
2526

2627
// Check remain requirements
2728
return this.createError({
28-
message: warning,
29+
message: decodeHtmlEntities(warning),
2930
path: this.path,
3031
});
3132
}

0 commit comments

Comments
 (0)