Validate the length of a string

@param  string $field
@param  mixed  $value
@param  array  $params

@internal param array $fields
@return bool
340496
protected function validateLength($field, $value, $params)
    {
        $length = $this->stringLength($value);
        // Length between
        if (isset($params[1])) {
            return $length >= $params[0] && $length <= $params[1];
        }

        // Length same
        return ($length !== false) && $length == $params[0];
    }
1265242
protected function _validate_length($value, $parameters)
    {
        $length = $this->_strlen($value);
        if (count($parameters) === 1) {
            $parameters = explode('-', $parameters[0]);
        }
        return $length >= $parameters[0] && $length <= $parameters[1] ? $value : null;
    }
842540
public static function typeArray($value, array $params, array $field)
    {
        if (!\is_array($value)) {
            return false;
        }

        if (isset($field['multiple'])) {
            if (isset($params['min']) && \count($value) < $params['min']) {
                return false;
            }

            if (isset($params['max']) && \count($value) > $params['max']) {
                return false;
            }

            $min = $params['min'] ?? 0;
            if (isset($params['step']) && (\count($value) - $min) % $params['step'] === 0) {
                return false;
            }
        }

        $options = $field['options'] ?? [];
        $use = $field['use'] ?? 'values';

        if (empty($field['selectize']) || empty($field['multiple'])) {
            $options = array_keys($options);
        }
        if ($use === 'keys') {
            $value = array_keys($value);
        }

        return !($options && array_diff($value, $options));
    }
718248
protected function validateContains($field, $value, $params)
    {
        if (!isset($params[0])) {
            return false;
        }
        if (!\is_string($value) || !\is_string($params[0])) {
            return false;
        }

        $strict = true;
        if (isset($params[1])) {
            $strict = (bool) $params[1];
        }

        if ($strict) {
            return \mb_strpos($value, $params[0]) !== false;
        }

        return \mb_stripos($value, $params[0]) !== false;
    }
829327
public function lengthBetween($field, $min, $max, $inclusive = false)
    {
        $fieldValue = strlen(trim($this->get($field)));

        $valid = ($fieldValue <= $max && $fieldValue >= $min);

        if (!$inclusive) {
            $valid = ($fieldValue < $max && $fieldValue > $min);
        }

        return ($valid === true) ?: $this->error($field, __FUNCTION__);
    }
285174
protected function validate_integer($field, $input, $param = null)
    {
        if (!isset($input[$field]) || empty($input[$field])) {
            return;
        }

        if (!filter_var($input[$field], FILTER_VALIDATE_INT)) {
            return array(
                'field' => $field,
                'value' => $input[$field],
                'rule' => __FUNCTION__,
                'param' => $param,
            );
        }
    }
1164615
public function validate($field, $value, $validator) {

		if(empty($value)) return false;
		if(!filter_var($value, FILTER_VALIDATE_URL)) return false;

		$url = parse_url($value);
		if(!in_array($url['scheme'], $this->allowed_protocols)) return false;

		if($this->allowed_domains === null) return true;

		return in_array($url['host'], $this->allowed_domains);

	}
251389
public static function minLength($value, $param)
    {
        $length = is_array($value) ? count($value) : mb_strlen($value);

        return $length >= $param;
    }
700758
public function validate($field, $input, array $params = array())
    {
        try {
            if ($input == '' || empty($params['0'])) {
                return false;
            }
            
            $params = $params['0'];
            if (empty($params['s3_access_key']) || empty($params['s3_secret_key']) || empty($params['s3_bucket'])) {
                return false;
            }
            
            $region = ($params['s3_region'] ? $params['s3_region'] : '');
            $client = m62S3::getRemoteClient($params['s3_access_key'], $params['s3_secret_key'], $region);
            if ($client->doesBucketExist($params['s3_bucket'])) {
                $filesystem = new Remote(new m62S3($client, $params['s3_bucket']));
                $filesystem->getAdapter()->listContents();
                return true;
            }
        } catch (\Exception $e) {
            return false;
        }
    }
596158
public static function typeWeek($value, array $params, array $field)
    {
        if (!isset($params['format']) && !preg_match('/^\d{4}-W\d{2}$/u', $value)) {
            return false;
        }

        return self::typeDatetime($value, $params, $field);
    }
393626
function checkFieldLength(parsed, field, length) {
  length = length || transactionFields[field].options.length;
  if (parsed.transactions[field] && parsed.transactions[field].toString().length > length) {
    console.log(parsed.transactions);
    console.log(field, parsed.transactions[field]);
  }
}
1248317
protected function validateEquals($field, $value, array $params)
    {
        // extract the second field value, this accounts for nested array values
        [$field2Value, $multiple] = $this->getPart($this->_fields, \explode('.', $params[0]));

        return null !== $field2Value && $value === $field2Value;
    }
480526
protected function validate_valid_url($field, $input, $param = null)
    {
        if (!isset($input[$field]) || empty($input[$field])) {
            return;
        }

        if (!filter_var($input[$field], FILTER_VALIDATE_URL)) {
            return array(
                'field' => $field,
                'value' => $input[$field],
                'rule' => __FUNCTION__,
                'param' => $param,
            );
        }
    }
1373792
protected function validateMin($field, $value, $params)
    {
        if (!\is_numeric($value)) {
            return false;
        }

        if (\function_exists('\bccomp')) {
            return !(\bccomp($params[0], $value, 14) === 1);
        }

        return $params[0] <= $value;
    }
992686
public function validate($field, $value, $validator) {
		if(strlen($value) === 0) return false;
		$value = (int) $value;
		return $value <= $this->max;
	}
477392
private function check($value, $params) {

		$value = strtotime($value);
		$param = strtotime($params[0]);

		if(true === is_int($value) && true === is_int($param)) {
			return true === ($value >= $param);
		}

		return false;
	}
405910
public static function typeCheckboxes($value, array $params, array $field)
    {
        // Set multiple: true so checkboxes can easily use min/max counts to control number of options required
        $field['multiple'] = true;

        return self::typeArray((array) $value, $params, $field);
    }