Collection edit: validate colors before allowing saving.

master
Tom Hacohen 4 years ago
parent 085298f14c
commit f6d4a72670

@ -81,12 +81,12 @@ export default function CollectionEdit(props: PropsType) {
saveErrors.name = fieldRequired; saveErrors.name = fieldRequired;
} }
if (selectedColor && !color) { if (color && !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(color)) {
saveErrors.color = "Must be of the form #RRGGBB or #RRGGBBAA or empty"; saveErrors.color = "Must be of the form #RRGGBB or #RRGGBBAA or empty";
} }
setErrors(saveErrors);
if (Object.keys(saveErrors).length > 0) { if (Object.keys(saveErrors).length > 0) {
setErrors(saveErrors);
return; return;
} }

Loading…
Cancel
Save