Last active
June 19, 2019 06:35
-
-
Save aire-con-gas/ea23432634dd0cfe9f9d590e96b721f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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