Skip to content

Commit

Permalink
fix: fix email validation
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinshilwal committed Mar 21, 2023
1 parent 47efa2d commit f733876
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/vue-form/src/schemas/Email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,22 @@ const schema = (
.string({
required_error: errorMessages.required,
})
.refine((value) => validator.isEmail(value, options || {}), {
message: errorMessages.invalid,
.superRefine((value, context) => {
if (value.length === 0) {
context.addIssue({
code: "invalid_string",
message: errorMessages.required,
validation: "email",
});
}

if (!validator.isEmail(value, options || {})) {
context.addIssue({
code: "invalid_string",
message: errorMessages.invalid,
validation: "email",
});
}
});
};

Expand Down

0 comments on commit f733876

Please sign in to comment.