UNPKG

@bigfishtv/cockpit

Version:

23 lines (21 loc) 746 B
import selectValue from 'lodash/get' /** * Returns a new formValue instance, by removing errors in externalErrorList * where the fields have changed compared with the values of lastFormValue * * For use with @bigfishtv/react-forms * * @param {ValueRoot} nextFormValue * @param {ValueRoot} lastFormValue * @return {ValueRoot} */ export default function invalidateExternalErrorList(nextFormValue, lastFormValue) { const externalErrorList = nextFormValue._externalErrorList.filter(error => { const path = error.field.replace(/^data\./, '') return selectValue(lastFormValue.value, path) === selectValue(nextFormValue.value, path) }) return nextFormValue.createRoot({ params: { forceShowErrors: true }, externalErrorList, }) }