Skip to content

Instantly share code, notes, and snippets.

@cbrannen9a
Created November 8, 2018 12:00
Show Gist options
  • Save cbrannen9a/852486eefa59c0de0ecb8cdf10a1a1ad to your computer and use it in GitHub Desktop.
Save cbrannen9a/852486eefa59c0de0ecb8cdf10a1a1ad to your computer and use it in GitHub Desktop.
Partial field validator
export const fieldValidator = (name, value) => {
let valid = false;
let message = '';
switch (name) {
case 'firstName':
valid = value.trim().length > 0;
message = validatorMessage(
valid,
'Please enter a First Name');
break;
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment