[Feature request] Add a 'validate' method to validate options object
See original GitHub issueautoNumeric being really customizable, the options you can pass as a parameter when initializing it can either get quite big, or you’d have a lot of different ones.
The bigger/numerous it gets, the likelier you’ll make a mistake there.
It would be great if there was a static autoNumeric function that would allow you to validate any configuration object to check if its structure, values and types are…valid.
You could imagine a function signature like autoNumeric.validate(myOptions) : boolean
, that would accept objects like myOptions
:
{
aSep: '.',
aDec: ',',
altDec: '.',
aSign: ' €',
pSign: 's',
mRound: 'U',
vMin: '0'
}
For instance, if you would pass vMin: 0
instead of vMin: '0'
, you would then be able to spot the error easily.
My use case is that I’m using quite a lot of autoNumeric-managed inputs in my templates, with multiple configurations (mainly currency/bare number/percentage, each localized). There, I use either pre-defined options objects, or directly objects in those templates, and I want to make sure other users would not break those when changing the autoNumeric options.
Additionaly, the validator would check if the myOptions
variable is not null, is an object, and that different autoNumeric options play well together, or respect basic rules (ie. in altDec
the currency symbol cannot contain an apostrophe, comma or numeric character).
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
You are very active 😉
Maybe you need a new person on your staff
You’re welcome 😃