// import Ember from 'ember';
import Validator from '../validator';

export default Validator.extend({
  options: {},

  errorMessages: {
    main: 'Value must be a whole number',

    min: 'Value must be larger than %@',
    max: 'Value must be smaller than %@',
  },

  call: function(value) {
    this.clearErrors();

    if(!this.isSet(value)) {
      return true;
    }

    var isValid = true;

    /* jshint ignore:start */
    if(value != parseInt(value) || Ember.isArray(value)) {
      isValid = false;
      this.addError('main');
    }
    /* jshint ignore:end */

    if(isValid) {
      value = parseInt(value);

      if(this.hasOption('min')) {
        if(value < this.get('options.min')) {
          isValid = false;
          this.addError('min', this.get('options.min'));
        }
      }

      if(this.hasOption('max')) {
        if(value > this.get('options.max')) {
          isValid = false;
          this.addError('max', this.get('options.max'));
        }
      }
    }

    return isValid;
  }
});

@@ -170,16 +170,17 @@
 e number
+.
 ',%0A%0A    
@@ -189,36 +189,26 @@
 n: '
-Value must be larger than
+Minimum value:
  %25@
+.
 ',%0A 
@@ -220,37 +220,26 @@
 x: '
-Value must be smaller than
+Maximum value:
  %25@
+.
 ',%0A 

Fix integer error messages