angular.validator.json
Description
Use json validator if you wish to restrict the user input to a valid JSON.
Usage
In HTML Template Binding
<input type="text" ng:validate="json"/>
In JavaScript
angular.validator.json(value);
Parameters
- value –
{string}
– value to validate
CSS
ng-validation-error
Example
<textarea name="json" cols="60" rows="5" ng:validate="json">
{name:'abc'}
</textarea>
it('should invalidate json', function(){
var n1 = element('.doc-example :input');
expect(n1.attr('className')).not().toMatch(/ng-validation-error/);
input('json').enter('{name}');
expect(n1.attr('className')).toMatch(/ng-validation-error/);
});