# angular.validator.integer

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

## Description

Use number validator to restrict the input to integers with an optional range. (See integer for whole numbers validator).

## Usage

### In HTML Template Binding

    <input type="text" ng:validate="integer[:min][:max]"/>

### In JavaScript

    angular.validator.integer(value[, min][, max])

### Parameters

- `value – {string} –`

  value to validate

- `min(optional=MIN_INT) – {int} –`

  minimum value.

- `max(optional=MAX_INT) – {int} –`

  maximum value.

## Example

      Enter integer: <input name="n1" ng:validate="integer" > <br>
      Enter integer equal or greater than 10: <input name="n2" ng:validate="integer:10" > <br>
      Enter integer between 100 and 200 (inclusive): <input name="n3" ng:validate="integer:100:200" > <br>

      it('should invalidate integer', function(){
       var n1 = element('.doc-example-live :input[name=n1]');
       expect(n1.attr('className')).not().toMatch(/ng-validation-error/);
       input('n1').enter('1.1');
       expect(n1.attr('className')).toMatch(/ng-validation-error/);
       var n2 = element('.doc-example-live :input[name=n2]');
       expect(n2.attr('className')).not().toMatch(/ng-validation-error/);
       input('n2').enter('10.1');
       expect(n2.attr('className')).toMatch(/ng-validation-error/);
       var n3 = element('.doc-example-live :input[name=n3]');
       expect(n3.attr('className')).not().toMatch(/ng-validation-error/);
       input('n3').enter('100.1');
       expect(n3.attr('className')).toMatch(/ng-validation-error/);
      });