Max length validator Validates that the value has to be a string with length equal to or less than the max length value specified
978931
function(value, attr, maxLength, model) {
        if (!_.isString(value) || value.length > maxLength) {
          return this.format(getMessageKey(this.msgKey, defaultMessages.maxLength), this.formatLabel(attr, model), maxLength);
        }
      }
27394
def _validate_empty(self, empty, field, value):
        
        if isinstance(value, Iterable) and len(value) == 0:
            self._drop_remaining_rules(
                'allowed', 'forbidden', 'items', 'minlength', 'maxlength',
                'regex', 'validator')
            if not empty:
                self._error(field, errors.EMPTY_NOT_ALLOWED)
855475
public function validateMaxLength($value)
  {
    if (!isset($this->attr["maxlength"])) return true;

		$maxlength = trim($this->attr["maxlength"]);
    $length = strlen($value);

    if ($length > $maxlength) {
      $this->errors[] =  "\"{$this->label}\" contains {$length} characters, but it is limited to {$maxlength} characters. Please shorten the length.";
			return false;
		}

		return true;
  }
1133300
function maxlength (val, max) {
  if (typeof val === 'string') {
    return isInteger(max, 10) && val.length <= parseInt(max, 10)
  } else if (Array.isArray(val)) {
    return val.length <= parseInt(max, 10)
  } else {
    return false
  }
}
419886
private static int getMaxLength( String[] values )
    {
        int result = 0;
        
        for ( int i = 0, curr = 0; i < values.length; i++ )
        {
            if ( ( curr = values[i].length() ) > result )
            {
                result = curr;
            }
        }
        return result;
    }
787489
def validate_wrap(self, value):
        '''  '''
        if not isinstance(value, basestring):
            self._fail_validation_type(value, basestring)
        if self.max is not None and len(value) > self.max:
            self._fail_validation(value, 'Value too long (%d)' % len(value))
        if self.min is not None and len(value) < self.min:
            self._fail_validation(value, 'Value too short (%d)' % len(value))
1281563
public function validateMaxLength()
    {
        $val = $this->val();

        if ($val === null && $this->allowNull()) {
            return true;
        }

        $maxLength = $this->maxLength();
        if ($maxLength == 0) {
            return true;
        }

        if (is_string($val)) {
            $valid = (mb_strlen($val) <= $maxLength);
            if (!$valid) {
                $this->validator()->error('Maximum length error', 'maxLength');
            }
        } else {
            $valid = true;
            foreach ($val as $v) {
                $valid = (mb_strlen($v) <= $maxLength);
                if (!$valid) {
                    $this->validator()->error('Maximum length error', 'maxLength');
                    return $valid;
                }
            }
        }

        return $valid;
    }
932149
function checkLength(size, schema, key) {
    //Check if it is an int
    if (Number.isInteger(schema[SCHEMALENGTH])) {
      if (size != schema[SCHEMALENGTH]) {
        throw new ValidationException("Size of " + key + " is not correct.");
      }
    } else if (typeof schema[SCHEMALENGTH] == "string") {
      if (
        size < getMin(schema[SCHEMALENGTH], key) ||
        size > getMax(schema[SCHEMALENGTH], key)
      ) {
        throw new ValidationException("Size of " + key + " is not correct.");
      }
    } else {
      throw new ValidationException(SCHEMALENGTH + " cast exception: " + key);
    }
  }
627554
private String limitStringLength(String str) {
    if (str.length() > MAX_STRING_LENGTH) {
      str = str.substring(0, MAX_STRING_LENGTH) + " ..."; 
    }
    return str;
  }
549578
def _validate_int(name, value, limits=(), strip='%'):
    '''
    
    '''
    comment = ''
    # Must be integral
    try:
        if isinstance(value, string_types):
            value = value.strip(' ' + strip)
        value = int(value)
    except (TypeError, ValueError):
        comment += '{0} must be an integer '.format(name)
    # Must be in range
    else:
        if len(limits) == 2:
            if value < limits[0] or value > limits[1]:
                comment += '{0} must be in the range [{1[0]}, {1[1]}] '.format(name, limits)
    return value, comment
1201482
def _validate_max(self, max_value, field, value):
        
        try:
            if value > max_value:
                self._error(field, errors.MAX_VALUE)
        except TypeError:
            pass
218535
function minmaxValidator(value, testValue, validityName, limit, compareFunction) {
                if (!angular.isUndefined(testValue) && limit) {
                    if (!ngModelCtrl.$isEmpty(value) && compareFunction) {
                        return testValue;
                    } else {
                        return value;
                    }
                }
                else {
                    if (!limit) {
                        ngModelCtrl.$setValidity(validityName, !compareFunction);
                    }
                    return value;
                }
            }
730533
private String trimValueIfExceedsMaxLength(String entry, String value) {
        if (value == null) {
            return null;
        }

        String result = value;
        Integer maximumSize = ENTRY_TO_MAX_SIZE.get(entry);
        if (maximumSize != null && value.length() > maximumSize) {
            result = value.substring(0, maximumSize);
        }
        return result;
    }
113803
public void validate(Object o)
    {
        if (o != null && o instanceof String)
        {
            int l = ((String)o).length();
            if (m_minLength != -1 && l < m_minLength)
            {
                String message = m_propertyMetadata.getMessageSourceAccessor().getMessage(m_message, new Object[]{ m_propertyMetadata.getLabelName(), m_minLength,m_maxLength,String.valueOf(o) });
                throw new ValidationException(message);                
            }
            if (m_maxLength != -1 && l > m_maxLength)
            {
                String message = m_propertyMetadata.getMessageSourceAccessor().getMessage(m_message, new Object[]{ m_propertyMetadata.getLabelName(),m_minLength,m_maxLength, String.valueOf(o) });
                throw new ValidationException(message);                
            }
        }
    }
917294
function (value, min, max) {
        min = min | 0;
        let length = ((value || '') + '').length;
        if (length < min) {
            return false;
        }
        if (max && length > max) {
            return false;
        }
        return true;
    }
1285947
def _validate(self, val):
        
        if self.allow_None and val is None:
            return

        if not isinstance(val, list):
            raise ValueError("List '%s' must be a list."%(self.name))

        if self.bounds is not None:
            min_length,max_length = self.bounds
            l=len(val)
            if min_length is not None and max_length is not None:
                if not (min_length <= l <= max_length):
                    raise ValueError("%s: list length must be between %s and %s (inclusive)"%(self.name,min_length,max_length))
            elif min_length is not None:
                if not min_length <= l:
                    raise ValueError("%s: list length must be at least %s."%(self.name,min_length))
            elif max_length is not None:
                if not l <= max_length:
                    raise ValueError("%s: list length must be at most %s."%(self.name,max_length))

        self._check_type(val)
43088
public function isValidStringLength($str, $min = null, $max = null): bool
    {
        $len = mb_strlen($str, 'UTF-8');

        return (($min !== null) && ($len >= $min)) || (($max !== null) && ($len <= $max));
    }