α
Size: a a a
α
DM
DM
α
α
DM
DM
α
javascript
setErrors = (errors) => { this.setState(() => ({ errors }))}
validate = async (data, schema) => {const parseErrors = err => err.inner.reduce(
(acc, cur) => ({ ...acc, [cur.path]: cur.errors }), {},)
schema
.validate(data)
.then(this.setErrors)
.catch(R.pipe(parseErrors, this.setErrors))
try {this.setErrors(await schema.validate(data))
} catch (err) {this.setErrors(parseErrors(err))
}
}
DM
α
promise.catch будет по сути catch из try...catch ?α
DM
α
α
α
DM
DM
DM
DM