Skip to content

Conversation

@dferrazm
Copy link

@dferrazm dferrazm commented May 21, 2021

It's now possible to set up a static validatorOptions object in the stimulus controller. This object will be used to pass any extra options accepted by validate.js.

Eg, validate.js has an option to skip prepending the error msgs with the attr name: fullMessages. When setting this option to false, instead of an error msg being "Foo can't be blank", it'll be "can't be blank".

It's now easy to pass this option (and others) by setting:

static rules = {...}
static validatorOptions = { fullMessages: false }

Note: this branch is based on julianrubisch fork which adds Stimulus 2.0 compatibility. We should merge that first.

@dferrazm dferrazm force-pushed the inject-validatejs-options branch from 48ab4f0 to 5659756 Compare May 21, 2021 11:51
It's now possible to set up a static `validatorOptions` object in the stimulus
controller. This object will be used to pass any extra options accepted by validate.js.

Eg, validate.js has an option to skip prepending the error msgs with the attr name: `fullMessages`.
When setting this option to false, instead of an error msg being "Foo can't be blank", it'll be
"can't be blank".

It's now easy to pass this option by setting:

   static rules = {...}
   static validatorOptions = { fullMessages: false }

---
@dferrazm dferrazm force-pushed the inject-validatejs-options branch from 5659756 to 04ce1b0 Compare May 24, 2021 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants