Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config of error message : Failure when defined via function + constraint is outOfRange or wrongLength #57

Open
er314 opened this issue Aug 24, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@er314
Copy link

er314 commented Aug 24, 2020

When configuring custom error message, for constraint outOfRange or wrongLength,
if it's done via a function (instead of via plain string),
then it fails.
ex : cfg.messages.outOfRange.over = function (field) { ... return myMessage; }

  • Cause : getErrorMessage supports both String + Function, but, for outOfRange and wrongLength, it calls String-only methods, without checking the input type :

/**
* Get the error message test
* @param {Node} field The field to get an error message for
* @param {Object} errors The errors on the field
* @param {Object} settings The plugin settings
* @return {:point_right:String|Function:point_left:} The error message
*/
var getErrorMessage = function (field, errors, settings) {
...
// Numbers that are out of range
if (errors.outOfRange) {
return messages.outOfRange[errors.outOfRange].:point_right:replace:point_left:('{max}', ...

er314 pushed a commit to er314/bouncer that referenced this issue Aug 24, 2020
… defined via function + constraint is outOfRange or wrongLength
er314 pushed a commit to er314/bouncer that referenced this issue Oct 8, 2020
… defined via function + constraint is outOfRange or wrongLength
@cferdinandi
Copy link
Owner

sorry y'all, this has just not been a priority for me at the moment. 😔

@cferdinandi cferdinandi added the bug Something isn't working label Feb 4, 2021
@cferdinandi
Copy link
Owner

I mean, I'm always open to PRs on this free software 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants