Allow validation functions in config
- Dominant language
- JavaScript
- Stars
- 19.4k
- Forks
- 3.1k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 9
Description
**Is your feature request related to a problem? Please describe.**
Doing good validation is a pain. Regex is just not that easy to work with, even for things as simple as validating a url or and email address. Additionally, being limited to a single regex param prevents leveraging the JS ecosystem.
**Describe the solution you'd like**
I'd like to be able to pass a validation function when configuring fields.
```js
{
name: 'email',
widget: 'string',
validate: (val) => isEmail(val) ? true : 'Must be a real email address.',
}
```
Allowing `async` functions would be even better.
**Describe alternatives you've considered**
I thought the `preSave` hook might help, but it doesn't look like `entry` has the proper api. And even if it did, it's a really roundabout way to validate a field.
Contributor guide
Assessment
This issue has not been assessed yet.