Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

How defining errorMessage with Custom Validation? #237

Open
Vic44tu opened this issue Apr 1, 2021 · 1 comment
Open

How defining errorMessage with Custom Validation? #237

Vic44tu opened this issue Apr 1, 2021 · 1 comment

Comments

@Vic44tu
Copy link

Vic44tu commented Apr 1, 2021

I would like to use Custom Validation and define error Message.
The example given in doc is with async function:
validate={{async: this.validate}}

  1. is it possible to use custom validate function without async call?
  2. is it possible to define simply the errorMessage?
    I tried (in functional component):
    validate={{validate: myValidate, errorMessage: "my error msg"}} but myValidate not called
    validate={{myValidate}} or validate={{validate: myValidate, ...}}; myValidate is called but errorMessage has to be stored and displayed on its own for example with AvFeedback
@TheSharpieOne
Copy link
Collaborator

TheSharpieOne commented Apr 1, 2021

  1. async is just a example key (I used it b/c the example also demonstrates how to do async stuff, but it probably made it less clear), it can be any key (such as myCustomAwesomeCode). IIRC, the key has no special meaning, it just cannot be one of the predefined validation keys.
  2. If the validation function returns a string, that string is used as the error message.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants