Formik: Is it possible to have non-field errors?

Created on 13 May 2018  路  4Comments  路  Source: formium/formik

Is your feature request related to a problem? Please describe.
My server returns errors that are not related to a particular field under the key '_error'. Currently when I try to set errors on formik, the errors are ignored because they do not match any keys in my values.

Describe the solution you'd like
I'd like for there to be the possibility of non-field errors stored in some sort of user specified key.

Describe alternatives you've considered
Alternatives would be...storing this in a values field, but that's hacky.

Additional context

stale

Most helpful comment

This is the kind of thing that status was meant to be used for.

When you get an error back from your server save it using setStatus(yourError) and access it from the status prop.

All 4 comments

This is the kind of thing that status was meant to be used for.

When you get an error back from your server save it using setStatus(yourError) and access it from the status prop.

Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.

ProBot automatically closed this due to inactivity. Holler if this is a mistake, and we'll re-open it.

This is the kind of thing that status was meant to be used for.

When you get an error back from your server save it using setStatus(yourError) and access it from the status prop.

As an addition (because this helped me):
Use as mentioned:

props.setStatus('Your error string')

But also access it in your template via props.status or if you prefer object destructuring:

const { status } = props
console.log(status) // 'Your error string'
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jordantrainor picture jordantrainor  路  3Comments

green-pickle picture green-pickle  路  3Comments

dfee picture dfee  路  3Comments

sibelius picture sibelius  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments