Skip to content

issue#90: email validation does not work #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/js/brutusin-json-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ if (typeof brutusin === "undefined") {
"exclusiveMaximum": "Value must be **lower than** `{0}`",
"minProperties": "At least `{0}` properties are required",
"maxProperties": "At most `{0}` properties are allowed",
"email": "The email must at least consists an asterisk (@), following by a domain name with a dot (.)",
"uniqueItems": "Array items must be unique",
"addItem": "Add item",
"true": "True",
Expand Down Expand Up @@ -277,6 +278,13 @@ if (typeof brutusin === "undefined") {
return BrutusinForms.messages["maxLength"].format(s.maxLength);
}
}
//Add a default regex pattern matching for email validation, or else user could use
//the `pattern` field for their own custom regex pattern
if (!s.pattern && s.format === "email") {
if (!value.match(/[^@\s]+@[^@\s]+\.[^@\s]+/)) {
return BrutusinForms.messages["email"];
}
}
}
if (value !== null && !isNaN(value)) {
if (s.multipleOf && value % s.multipleOf !== 0) {
Expand Down