Validating data in javascript

You can use the async validate function even if no validations are async, it still returns a promise.You can not, however, use the regular function with async validations.The implementation is fairly basic and doesn't do anything clever with the messages.It doesn't support things like only validating a sub key if the parent key is present so for more advanced validations multiple validation schemas are recommended. Most validators allow you to specify default messages in addition to default options, refer to the documentation for the individual validators for information on how to do this.provides a declarative way of validating javascript objects.It is unit tested with 100% code coverage and can be considered fit for production.The message can also be a function which will be called to retrieve the message, besides this it is treated like a normal message (the attribute name is prepended etc).If the message is not a function and not a string it is simply returned as is.

The errors has the same format as the errors from the regular validation function.

The project can be found on Git Hub where you can also find our issue tracker.

There is also a Travis project used for testing, a Coveralls project used to code coverage as well as the annotated source.

If the attributes objects is an HTML/DOM/j Query element Even though none of the built in validators are async it is sometimes useful to have async validations.

One example would be to check if a username is already used by asking the server.

Search for validating data in javascript:

validating data in javascript-38

The attributes must be a plain object or a form element, things like backbone models etc are not supported.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “validating data in javascript”

  1. Never mind the fact that more than one-third of all people who use online dating sites have never actually gone on a date with someone they met online, those that somehow do manage to find someone else they are willing to marry who is willing to marry them (a vanishingly tiny subset of online daters) face an uphill battle.