2021-04-12 13:32:25 +00:00
|
|
|
import { size, startsWith } from "lodash";
|
2016-11-16 16:58:25 +00:00
|
|
|
|
|
|
|
|
const validate = (formData) => {
|
|
|
|
|
const errors = {};
|
2021-04-12 13:32:25 +00:00
|
|
|
const { org_name: orgName, org_logo_url: orgLogoUrl } = formData;
|
2016-11-16 16:58:25 +00:00
|
|
|
|
|
|
|
|
if (!orgName) {
|
2021-04-12 13:32:25 +00:00
|
|
|
errors.org_name = "Organization name must be present";
|
2016-11-16 16:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
if (orgLogoUrl && !startsWith(orgLogoUrl, "https://")) {
|
|
|
|
|
errors.org_logo_url = "Organization logo URL must start with https://";
|
2016-11-16 16:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const valid = !size(errors);
|
|
|
|
|
|
|
|
|
|
return { valid, errors };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default { validate };
|