Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

3rd Party Addons

Ghislain B. edited this page Oct 5, 2015 · 14 revisions

Since version 1.4.9

What if you want to validate an input which is an Array of Strings or is using a 3rd party addon? Well Angular-Validation can now validate that too. As long as you follow the requirement and the code examples, you should be fine.

#####Requirements

  • Input element requires a name attributes.
  • ngModel needs to be filled and need to be an Array of Strings or an Array of Objects
    • Array of Objects, for Angular-Validation to work it needs to know which object property you want to reference. Example var laptops = [{ id: 0, manufacturer: 'Acer' }, { id: 1, manufacturer: 'Lenovo' }]; The property we would most probably like to to validate is manufacturer in this case.

#####Code Sample This only work with the Directive for now. ######Directive (html) HTML Code

<!-- Example with ngTagsInput addon -->
<tags-input name="input1"
            ng-model="vm.tags1"
            validation="in_list:Tag4,Tag5|required"
            validation-array-objprop="text">
</tags-input>

JavaScript Code

myApp.controller('Ctrl', ['validationService', function (validationService) {
  var vm = this;
  var myValidation = new validationService({ controllerAs: vm, formName: 'vm.test' });

  vm.tags1 = [
    { id: 1, text: 'Tag1' },
    { id: 2, text: 'Tag2' },
    { id: 3, text: 'Tag3' }
  ];
Clone this wiki locally