src/Koldy/Validator.php
protected function validateMin($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        if (count($args) == 0) {
            throw new ValidatorConfigException('Validator \'min\' has to have defined minimum value');
        }

        $minSize = $args[0] ?? null;

        if (!is_numeric($minSize)) {
            throw new ValidatorConfigException('Validator \'min\' has non-numeric value');
        }

        $minSize = (int)$minSize;

        //$value = $this->getValue($parameter);

        if ($value === null) {
            return null;
        }

        if (is_array($value) && in_array('array', $rules)) {
            // we got an array, so let's check the array size

            if (count($value) >= $minSize) {
                return null;
            }

            return Message::getMessage(Message::MIN_VALUE, [
                'param' => $parameter,
                'min' => $minSize,
                'value' => $value
            ]);
        }

        if (!is_scalar($value)) {
            return Message::getMessage(Message::PRIMITIVE, [
                'param' => $parameter
            ]);
        }

        $value = (string)$value;

        if ($value === '') {
            return null;
        }

        if (!is_numeric($value)) {
            return Message::getMessage(Message::NUMERIC, [
                'param' => $parameter,
                'value' => $value
            ]);
        }

        $value += 0;

        if ($value < $minSize) {
            return Message::getMessage(Message::MIN_VALUE, [
                'param' => $parameter,
                'min' => $minSize,
                'value' => $value
            ]);
        }

        return null;
    }
protected function validateMin($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        if (count($args) == 0) {
            throw new ValidatorConfigException('Validator \'min\' has to have defined minimum value');
        }

        $minSize = $args[0] ?? null;

        if (!is_numeric($minSize)) {
            throw new ValidatorConfigException('Validator \'min\' has non-numeric value');
        }

        $minSize = (int)$minSize;

        //$value = $this->getValue($parameter);

        if ($value === null) {
            return null;
        }

        if (is_array($value) && in_array('array', $rules)) {
            // we got an array, so let's check the array size

            if (count($value) >= $minSize) {
                return null;
            }

            return Message::getMessage(Message::MIN_VALUE, [
                'param' => $parameter,
                'min' => $minSize,
                'value' => $value
            ]);
        }

        if (!is_scalar($value)) {
            return Message::getMessage(Message::PRIMITIVE, [
                'param' => $parameter
            ]);
        }

        $value = (string)$value;

        if ($value === '') {
            return null;
        }

        if (!is_numeric($value)) {
            return Message::getMessage(Message::NUMERIC, [
                'param' => $parameter,
                'value' => $value
            ]);
        }

        $value += 0;

        if ($value < $minSize) {
            return Message::getMessage(Message::MIN_VALUE, [
                'param' => $parameter,
                'min' => $minSize,
                'value' => $value
            ]);
        }

        return null;
    }
protected function validateMin ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { if ( count ( $ args ) == 0 ) { throw new ValidatorConfigException ( 'Validator \'min\' has to have defined minimum value' ) ; } $ minSize = $ args [ 0 ] ?? null ; if ( ! is_numeric ( $ minSize ) ) { throw new ValidatorConfigException ( 'Validator \'min\' has non-numeric value' ) ; } $ minSize = ( int ) $ minSize ; //$value = $this->getValue($parameter); if ( $ value === null ) { return null ; } if ( is_array ( $ value ) && in_array ( 'array' , $ rules ) ) { // we got an array, so let's check the array size if ( count ( $ value ) >= $ minSize ) { return null ; } return Message :: getMessage ( Message :: MIN_VALUE , [ 'param' => $ parameter , 'min' => $ minSize , 'value' => $ value ] ) ; } if ( ! is_scalar ( $ value ) ) { return Message :: getMessage ( Message :: PRIMITIVE , [ 'param' => $ parameter ] ) ; } $ value = ( string ) $ value ; if ( $ value === '' ) { return null ; } if ( ! is_numeric ( $ value ) ) { return Message :: getMessage ( Message :: NUMERIC , [ 'param' => $ parameter , 'value' => $ value ] ) ; } $ value += 0 ; if ( $ value < $ minSize ) { return Message :: getMessage ( Message :: MIN_VALUE , [ 'param' => $ parameter , 'min' => $ minSize , 'value' => $ value ] ) ; } return null ; }
Validate if value has the minimum value of

@param mixed $value
@param string $parameter
@param array $args
@param array $rules other rules
@param array|null $context

@return null|string
@throws ValidatorConfigException
@example 'param' => 'min:5' - will fail if value is not at least 5
Validate if value has the minimum value of