mirror of
https://github.com/empayre/fleet.git
synced 2024-11-08 01:38:57 +00:00
aeb852e168
* Remove username from UI code * Remove username from tests * Remove username from database * Modify server endpoints for removing username * Implement backend aspects of removing username * Update API docs * Add name to fleetctl
39 lines
816 B
JavaScript
39 lines
816 B
JavaScript
import { size } from "lodash";
|
|
import validateEquality from "components/forms/validators/validate_equality";
|
|
|
|
const validate = (formData) => {
|
|
const errors = {};
|
|
const {
|
|
name,
|
|
password,
|
|
password_confirmation: passwordConfirmation,
|
|
} = formData;
|
|
|
|
if (!name) {
|
|
errors.name = "Full name must be present";
|
|
}
|
|
|
|
if (
|
|
password &&
|
|
passwordConfirmation &&
|
|
!validateEquality(password, passwordConfirmation)
|
|
) {
|
|
errors.password_confirmation =
|
|
"Password confirmation does not match password";
|
|
}
|
|
|
|
if (!password) {
|
|
errors.password = "Password must be present";
|
|
}
|
|
|
|
if (!passwordConfirmation) {
|
|
errors.password_confirmation = "Password confirmation must be present";
|
|
}
|
|
|
|
const valid = !size(errors);
|
|
|
|
return { valid, errors };
|
|
};
|
|
|
|
export default { validate };
|