# angular.validator.json

Work in Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

## 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

## Example

      <textarea name="json" cols="60" rows="5" ng:validate="json">
      {name:'abc'}
      </textarea>

      it('should invalidate json', function(){
       var n1 = element('.doc-example-live :input');
       expect(n1.attr('className')).not().toMatch(/ng-validation-error/);
       input('json').enter('{name}');
       expect(n1.attr('className')).toMatch(/ng-validation-error/);
      });