Last active
November 24, 2017 22:47
-
-
Save ndelitski/c9f85a2718d4b3580bc461e26a5a4c37 to your computer and use it in GitHub Desktop.
This file contains 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
const formErrors = { | |
budget: { | |
amount: 'Required', | |
}, | |
project: { | |
name: 'Required', | |
}, | |
empty: null, | |
} | |
R.pipe( | |
R.toPairs, | |
R.filter(R.last), | |
// TODO use ramda here! | |
forms => [ | |
// stop submit for every form | |
R.map(R.apply(stopSubmitForm))(forms), | |
// focus for first form error | |
R.pipe( | |
R.head, | |
([form, errors]) => [form, R.head(R.keys(errors))], | |
R.apply(focusFormField) | |
)(forms), | |
], | |
R.flatten | |
)(formErrors) | |
// should output stopSubmitForm('budget'), stopSubmit('project'), focus('budget', 'amount') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment