Skip to content

Instantly share code, notes, and snippets.

@aire-con-gas
Last active June 19, 2019 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aire-con-gas/ea23432634dd0cfe9f9d590e96b721f9 to your computer and use it in GitHub Desktop.
Save aire-con-gas/ea23432634dd0cfe9f9d590e96b721f9 to your computer and use it in GitHub Desktop.
function someDeclarativeMethod(setting, items, response) {
var emptyMessage = {
message: "You have not selected anything"
};
if (
aService.isThisFooSetting(setting.type) &&
!aService.isEditModeClear(setting.editMode) &&
items.length === 0
) {
response.errors.push(emptyMessage);
}
if (
aService.isThisBarSetting(setting.type) &&
!aService.isEditModeClear(setting.editMode) &&
items.length === 0
) {
response.errors.push(emptyMessage);
}
response.errors = items.reduce(errors, item => {
const errs = item.checkForErrors();
errs.length > 0 && errors.push(errs);
return errors;
}, []);
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment