refactor out OrganizationForm; share between add & edit

This commit is contained in:
Keith Grant
2019-03-27 15:29:46 -04:00
parent 40b2539626
commit 64e933acb4
4 changed files with 239 additions and 247 deletions

19
src/util/validators.js Normal file
View File

@@ -0,0 +1,19 @@
import { i18nMark } from '@lingui/react';
export function required (message) {
return value => {
if (!value.trim()) {
return message || i18nMark('This field must not be blank');
}
return undefined;
};
}
export function maxLength (max) {
return value => {
if (value.trim() > max) {
return i18nMark(`This field must not exceed ${max} characters`);
}
return undefined;
};
}