-
Notifications
You must be signed in to change notification settings - Fork 40
API Reference
Brian Donovan edited this page Aug 23, 2013
·
3 revisions
Wiki ▸ API Reference
Everything in this library is contained in a module, which by default is
exported as LGTM
in the browser. The documentation will assume that the
module is exposed in your code as LGTM
, whether using globals, AMD, or
CommonJS.
This is the main API you'll want to use. It is the API used in all the examples.
-
LGTM.validator - factory method for creating a
ValidatorBuilder
- builder.validates - start validations for an attribute
- builder.using - add a validation for the current attribute
- builder.when - make some validations conditional
-
builder.build - build an
ObjectValidator
- core.required - validate that a value is present
- core.optional - only validate if a value is present
- core.email - validate that the value is an email
- core.minLength - validate that the value has a minimum length
- core.maxLength - validate that the value has a maximum length
This is the core API underlying ValidatorBuilder
.
- validator.validate - performs validations against a given object
- validator.attributes - lists all the attributes directly or indirectly used in validation
-
validator.addValidation - registers a validation for a given attribute
[internal]
-
validator.addDependentsFor - registers dependencies between attributes
[internal]