src/Koldy/Validator.php
protected function validateSlug($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        //$value = $this->getValue($parameter);

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

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

        $value = trim((string)$value);

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

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

        return null;
    }
protected function validateSlug($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        //$value = $this->getValue($parameter);

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

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

        $value = trim((string)$value);

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

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

        return null;
    }
protected function validateSlug ( $ value , string $ parameter , array $ args = [ ] , array $ rules = null , array $ context = null ) : ? string { //$value = $this->getValue($parameter); if ( $ value === null ) { return null ; } if ( ! is_scalar ( $ value ) ) { return Message :: getMessage ( Message :: PRIMITIVE , [ 'param' => $ parameter ] ) ; } $ value = trim ( ( string ) $ value ) ; if ( $ value === '' ) { return null ; } if ( ! Validate :: isSlug ( $ value ) ) { return Message :: getMessage ( Message :: SLUG , [ 'param' => $ parameter , 'value' => $ value ] ) ; } return null ; }
Validate if given value is valid URL slug

@param mixed $value
@param string $parameter
@param array $args
@param array $rules other rules

@return null|string
@throws ValidatorConfigException
@example 'param' => 'slug'
Validate if given value is valid URL slug