Alejandra
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
12 additions and
5 deletions
-
frontend/src/utils.ts
|
@ -1,8 +1,13 @@ |
|
|
export const emailPattern = { |
|
|
export const emailPattern = { |
|
|
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i, |
|
|
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i, |
|
|
message: "Invalid email address", |
|
|
message: "Invalid email address", |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const namePattern = { |
|
|
|
|
|
value: /^[A-Za-z\s\u00C0-\u017F]{1,30}$/, |
|
|
|
|
|
message: "Invalid name", |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export const passwordRules = (isRequired = true) => { |
|
|
export const passwordRules = (isRequired = true) => { |
|
|
const rules: any = { |
|
|
const rules: any = { |
|
|
minLength: { |
|
|
minLength: { |
|
@ -23,13 +28,15 @@ export const confirmPasswordRules = ( |
|
|
isRequired = true, |
|
|
isRequired = true, |
|
|
) => { |
|
|
) => { |
|
|
const rules: any = { |
|
|
const rules: any = { |
|
|
validate: (value: string) => |
|
|
validate: (value: string) => { |
|
|
value === getValues().password || "The passwords do not match", |
|
|
const password = getValues().password || getValues().new_password; |
|
|
|
|
|
return value === password ? true : "The passwords do not match"; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (isRequired) { |
|
|
if (isRequired) { |
|
|
rules.required = "Password confirmation is required" |
|
|
rules.required = "Password confirmation is required"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return rules |
|
|
return rules; |
|
|
} |
|
|
} |
|
|