You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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}', ...
Solution : Perform the String-only text replacement only if input type is String.
See pull-request Proposed fix for Issue #57 #58 for proposed fix.
The text was updated successfully, but these errors were encountered:
er314
pushed a commit
to er314/bouncer
that referenced
this issue
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; }
/**
* 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}', ...
See pull-request Proposed fix for Issue #57 #58 for proposed fix.
The text was updated successfully, but these errors were encountered: