<commit_before>var _ = require('../../../../ui-base/_');

function stringBytes(c){
  var n=c.length,s;
  var len=0;
  for(var i=0; i <n;i++){
   s=c.charCodeAt(i);
   while( s > 0 ){
      len++;
      s = s >> 8;
   }
  }
  return len;
}

module.exports = {
  required: {type:'isRequired', message: _.$trans('PLEASE_INPUT')},
  isEmail: {type:'isEmail', message: _.$trans('FORMAT_ERROR')},
  isURL: {type:'isURL', message: _.$trans('FORMAT_ERROR')},
  isInt: function(min, max, message) {
    min = min/1 || -Infinity;
    max = max/1 || Infinity;
    return {type:'isInt', message:message || _.$trans('VALUE_ERROR'), options:{min:min, max:max}};
  },
  isFloat: function(min, max, message) {
    min = min/1 || -Infinity;
    max = max/1 || Infinity;
    return {type:'isFloat', message:message || _.$trans('VALUE_ERROR'), options:{min:min, max:max}};
  },
  byteLen: function(min, max, message) {
    min = min || 0;
    max = max || Infinity;
    return {message:message || _.$trans('LENGTH_ERROR'), method: function(value) {
      value = value || '';
      var len = stringBytes(value);
      return len >= min && len <= max;
    }};
  }
};<commit_msg>fix(ui.input): fix validation error of min & max #74<commit_after>var _ = require('../../../../ui-base/_');

function stringBytes(c){
  var n=c.length,s;
  var len=0;
  for(var i=0; i <n;i++){
   s=c.charCodeAt(i);
   while( s > 0 ){
      len++;
      s = s >> 8;
   }
  }
  return len;
}

module.exports = {
  required: {type:'isRequired', message: _.$trans('PLEASE_INPUT')},
  isEmail: {type:'isEmail', message: _.$trans('FORMAT_ERROR')},
  isURL: {type:'isURL', message: _.$trans('FORMAT_ERROR')},
  isInt: function(min, max, message) {
    min = isNaN(min/1) ? min/1 : -Infinity;
    max = isNaN(max/1) ? max/1 : Infinity;
    return {type:'isInt', message:message || _.$trans('VALUE_ERROR'), options:{min:min, max:max}};
  },
  isFloat: function(min, max, message) {
    min = isNaN(min/1) ? min/1 : -Infinity;
    max = isNaN(max/1) ? max/1 : Infinity;
    return {type:'isFloat', message:message || _.$trans('VALUE_ERROR'), options:{min:min, max:max}};
  },
  byteLen: function(min, max, message) {
    min = isNaN(min/1) ? min/1 : 0;
    max = isNaN(max/1) ? max/1 : Infinity;
    return {message:message || _.$trans('LENGTH_ERROR'), method: function(value) {
      value = value || '';
      var len = stringBytes(value);
      return len >= min && len <= max;
    }};
  }
};
{'fraction_non_alphanumeric': 0.21121571837904216, 'fraction_numerical': 0.011461318051575931, 'mean_word_length': 3.272727272727273, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4931109', 'n_tokens_mistral': 902, 'n_tokens_neox': 894, 'n_words': 197}