angular-object-validator

0.0.1 • Public • Published

AngularJS Object Validator

AngularJS object validator. This is the initial implementation however, I'll be working further to improve functionality and abilities as well as observing nested objects. Better documentation will also be introduced in the near future.

Build Status

Installation

install angular-object-validator

Allowed validations:

  • required

Data types:

  • number
  • array
  • string
  • object
  • boolean

Calculations:

  • min
  • max
  • greaterThan
  • lessThan
  • greaterThanOrEquals
  • lessThanOrEquals

Example usage:

You can pass a single object or an array of objects to be validated.

app.controller('AppCtrl', function(ObjectValidator) {
    // Set validation rules.
    var rules = [
        {
            "quantity": [
                { 'required': 'Quantity received must be present' },
                { '{lessThanOrEquals:quantityOrdered}': 'Quantity received must be less than or equal to quantity ordered' }
            ]
        }
    ];

    ObjectValidator.validate([{}, {}, {}], rules).then(function() {
        // Validation passed
    }).catch(function(errors) {
        // Errors are returned as an array
    });
});

Package Sidebar

Install

npm i angular-object-validator

Weekly Downloads

1

Version

0.0.1

License

none

Last publish

Collaborators

  • hycner
  • iamcutler