Skip to content

Instantly share code, notes, and snippets.

@Qquanwei
Last active March 14, 2019 09:16
Show Gist options
  • Save Qquanwei/f5842acff8de22021316c4a1858042b6 to your computer and use it in GitHub Desktop.
Save Qquanwei/f5842acff8de22021316c4a1858042b6 to your computer and use it in GitHub Desktop.
OverAssert
function submit(data) {
let errorMessage = '';
if (!data.name) {
errorMessage = 'please input name';
} else if (data.lastName && data.lastName.length > 10) {
errorMessage = 'length of lastName should less than 10 ';
} else if (data.age < 80) {
errorMessage = 'age should less than 80';
} else if (data.experience > 3) {
errorMessage = 'experience should large than 3';
}
...
...
if (errorMessage) {
//return and show
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment