mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
## Addresses #11338 - Validate emails on login page - Fix jumping error state for no email provided ("Email field must be completed") - Fix jumping error state for password field - Fix jumping error state for Forgot password > email field https://www.loom.com/share/92a238fcd2614d6e8d2655d571aa2757 # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/` - [x] Added/updated tests - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <[email protected]>
24 lines
650 B
JavaScript
24 lines
650 B
JavaScript
import { size } from "lodash";
|
|
import validatePresence from "components/forms/validators/validate_presence";
|
|
import validateEmail from "components/forms/validators/valid_email";
|
|
|
|
const validate = (formData) => {
|
|
const errors = {};
|
|
const { password, email } = formData;
|
|
|
|
if (!validatePresence(email)) {
|
|
errors.email = "Email field must be completed";
|
|
} else if (!validateEmail(email)) {
|
|
errors.email = "Email must be a valid email address";
|
|
}
|
|
|
|
if (!validatePresence(password)) {
|
|
errors.password = "Password field must be completed";
|
|
}
|
|
|
|
const valid = !size(errors);
|
|
|
|
return { valid, errors };
|
|
};
|
|
|
|
export default validate;
|