Validate that an attribute has a given number of digits.

@param  mixed $value
@param  array $parameters

@return bool
436440
public function isDigits($value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'digits');

        return !preg_match('/[^0-9]/', $value)
               && strlen((string)$value) == $parameters[0];
    }
461532
final public static function hasNumber ($value, array $options=[]) : bool
	{
		if (!self::hasValue($value))  new ErrorCode(1001);

		// Submitted values are strings, so use is_numeric instead of is_int
		if (!is_numeric($value)) return FALSE;

		if (!empty($options)) return static::hasLength($value, $options);

		return TRUE;
	}
523627
protected function validateUsername($attribute, $value, $parameters)
    {
        // Use provided regex or use fallback
        $pattern = ! empty($parameters[0]) ? $parameters[0] : '/^([a-zA-Z0-9._-])+$/i';

        return (bool) preg_match($pattern, $value);
    }
373569
public function validateValidatorList($attribute, $value, $parameters)
    {
        $validators = Input::get('validators');
        if (!is_null($validators)) {
            foreach ($validators as $index => $id) {
                if (isset($value[$id]) && $value[$id] == '') {
                    $this->setCustomMessages(["validator_custom[{$id}]" => trans('antares/customfields::validator.create.validators-empty-fields')]);
                    $this->addFailure("validator_custom[{$id}]", "validator_custom[{$id}]", []);
                    break;
                }
            }
        }

        return true;
    }
1174336
protected function validateMin( $value, $attribute, array $parameters )
	{
		$this->requireParameterCount( 1, $parameters, 'min' );

		return $this->getSize( $attribute, $value ) >= $parameters[0];
	}
1304039
public function isDigitsBetween($value, $parameters)
    {
        $this->requireParameterCount(2, $parameters, 'digits_between');

        $length = strlen((string)$value);

        return !preg_match('/[^0-9]/', $value)
               && $length >= $parameters[0] && $length <= $parameters[1];
    }
758943
protected function validateSame($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'same');

        $other = Arr::get($this->data, $parameters[0]);

        return (isset($other) && $value == $other);
    }
1294049
public function validateIn($attribute, $value, $parameters)
    {
        if (is_array($value) && $this->hasRule($attribute, 'Array')) {
            foreach ($value as $element) {
                if (is_array($element)) {
                    return false;
                }
            }

            return count(array_diff($value, $parameters)) === 0;
        }

        return ! is_array($value) && in_array((string) $value, $parameters);
    }
923412
protected function validateMax( $attribute, $value, $parameters )
	{
		$this->requireParameterCount( 1, $parameters, 'max' );

		if ( $value instanceof UploadedFile && !$value->isValid() )
		{
			return false;
		}

		return $this->getSize( $attribute, $value ) <= $parameters[0];
	}
1275972
protected function validateExists($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'exists');

        list($connection, $table) = $this->parseTable($parameters[0]);

        // The second parameter position holds the name of the column that should be
        // verified as existing. If this parameter is not specified we will guess
        // that the columns being "verified" shares the given attribute's name.
        $column = isset($parameters[1]) ? $parameters[1] : $attribute;

        $expected = (is_array($value)) ? count($value) : 1;

        return $this->getExistCount($connection, $table, $column, $value, $parameters) >= $expected;
    }
928126
protected function _validate_range($value, $parameters)
    {
        /** @noinspection CallableParameterUseCaseInTypeContextInspection */
        $value = $this->_validate_float($value);

        return $value === null || $value < $parameters[0] || $value > $parameters[1] ? null : $value;
    }
910524
protected function validateRegex($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'regex');

        return preg_match($parameters[0], $value);
    }
535016
public function validateNameOnCreate($attribute, $value, $parameters)
    {
        $groupId = Input::get('group');
        $typeId  = Input::get('type');
        $exists  = Foundation::make('antares.customfields.model.view')
                ->query()
                ->where('group_id', $groupId)
                ->where('type_id', $typeId)
                ->where('name', $value)
                ->exists();
        if ($exists) {
            $this->setCustomMessages(['name-on-create' => trans('antares/customfields::validator.create.name-non-unique')]);
            $this->addFailure($attribute, 'name-on-create', []);
            return false;
        }


        return true;
    }
802805
public function validateVatNumber($attribute, $value, $parameters, $validator)
    {
        $validator->setCustomMessages([
            'vat_number' => $validator->getTranslator()->get('vatnumber-validator::validation.vat_number'),
        ]);

        try {
            return VatCalculator::isValidVATNumber($value);
        } catch (VATCheckUnavailableException $e) {
            return false;
        }
    }
505852
protected function validateBefore($attribute, $value, $parameters)
	{
		if ( ! ($date = strtotime($parameters[0])))
		{
			return strtotime($value) < strtotime($this->getValue($parameters[0]));
		}
		else
		{
			return strtotime($value) < $date;
		}
	}
532612
public function validateMimes($attribute, $value, $parameters)
    {
        if (! $this->isValidFileInstance($value)) {
            return false;
        }

        if ($this->shouldBlockPhpUpload($value, $parameters)) {
            return false;
        }

        return $value->getPath() !== '' && in_array($value->guessExtension(), $parameters);
    }
9843
protected function validateDateFormat($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'date_format');

        $parsed = date_parse_from_format($parameters[0], $value);

        return $parsed['error_count'] === 0 && $parsed['warning_count'] === 0;
    }