question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature request] Add a 'validate' method to validate options object

See original GitHub issue

autoNumeric 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:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
BobKnothecommented, Nov 8, 2016

You are very active 😉

Maybe you need a new person on your staff

0reactions
AlexandreBonneaucommented, Dec 28, 2016

You’re welcome 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Client-side form validation - Learn web development | MDN
Client-side validation is an initial check and an important feature of good ... Built-in form validation uses HTML form validation features, ...
Read more >
Documentation - jQuery Validation Plugin
The validate method returns a Validator object that has a few public methods that you can use to trigger validation programmatically or change...
Read more >
Add runtime validation to models · Issue #3528 - GitHub
Provide a validate function for models which is based on the Prisma schema: model User { id Int @default(autoincrement()) @id email String ...
Read more >
Validating Input | Web Accessibility Initiative (WAI) - W3C
HTML5 defines a range of built-in functionality to validate common types of input, such as email addresses and dates. In some situations, such...
Read more >
Object Validation - Core Data Programming Guide
How to validate is a model decision, when to validate is a user interface or controller-level decision. For example, a value binding for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found