@ag04/react-utils
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

React utils

npm version

Documentation

parseFormErrors

Parses spring-form errors to redux-form error object.

VERSION 0.0.7

parseFormErrors(errors: FormFieldError[]): ParsedFormErrors

interface FormFieldError { defaultMessage: string, field: string }

type ParsedFormErrors = { ​[fieldName: string]: string }

👉 example
    api.post("/foo", fooFormData)
            .then(res => res.data)
            .catch(e => { 
                    // map spring form error arrray to redux-form error object
                   const errors = parseFormErrors(e.response.data.errors);
                   
                   // show field errors in form
                   dispatch(reduxForm.stopSubmit(errors));
             });

VERSION 1.0.0

parseFormErrors now expects object to have property "message" instead of "defaultMessage"

Dependencies (0)

    Dev Dependencies (30)

    Package Sidebar

    Install

    npm i @ag04/react-utils

    Weekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    9.27 kB

    Total Files

    14

    Last publish

    Collaborators

    • antegulin
    • bstojanovic
    • mario.lukec
    • sgrabar