2018-03-25 18:03:08 +00:00
|
|
|
// License: LGPL-3.0-or-later
|
2018-03-25 17:30:42 +00:00
|
|
|
const h = require('flimflam/h')
|
|
|
|
const R = require('ramda')
|
|
|
|
const validatedForm = require('flimflam/ui/validated-form')
|
|
|
|
|
|
|
|
module.exports = R.curryN(2, (formState, field) => {
|
|
|
|
const key = R.path(['data','props','name'], field)
|
|
|
|
const validatedField = validatedForm.field(formState, field)
|
|
|
|
const err = formState.errors$()[key]
|
|
|
|
return h('div', {
|
|
|
|
attrs: {'data-ff-field': err ? 'invalid' : 'valid', 'data-ff-field-error': err || ''}
|
|
|
|
}, [ validatedField ])
|
|
|
|
})
|
|
|
|
|