import ConfigFieldBaseType from './base';

class NumberType extends ConfigFieldBaseType {
  constructor(min, max) {
    super();

    this.validators.push(val => typeof val === 'number');

    if (min !== null && min !== undefined) {
      this.validators.push(val => val > min);
    }

    if (max !== null && max !== undefined) {
      this.validators.push(val => val < max);
    }
  }
}

module.exports = NumberType;

import BaseType from './base';

class NumberType extends BaseType {
  constructor({ min, max } = {}) {
    super();

    this.transformators.pre.push(val => Number(val));

    this.validators.push(val => !isNaN(val));

    this.validators.push(val =>
      ((typeof min === 'number') ? val >= min : true));

    this.validators.push(val =>
      ((typeof max === 'number') ? val <= max : true));
  }
}

module.exports = NumberType;

Edit validation and transformation process in Number type
feat(types): Edit validation and transformation process in Number type
