src/Type/AbstractBinaryType.php
public function guard($value, Field $field)
    {
        Assertion::string($value, null, $field->getName());

        // intentionally using strlen to get byte length, not mb_strlen
        $length = $this->encodeToBase64 ? strlen($this->encode($value, $field)) : strlen($value);
        $minLength = $field->getMinLength();
        $maxLength = NumberUtils::bound($field->getMaxLength(), $minLength, $this->getMaxBytes());
        $okay = $length >= $minLength && $length <= $maxLength;

        Assertion::true(
            $okay,
            sprintf(
                'Field [%s] must be between [%d] and [%d] bytes, [%d] bytes given.',
                $field->getName(),
                $minLength,
                $maxLength,
                $length
            ),
            $field->getName()
        );
    }
public function guard($value, Field $field)
    {
        Assertion::string($value, null, $field->getName());

        // intentionally using strlen to get byte length, not mb_strlen
        $length = $this->encodeToBase64 ? strlen($this->encode($value, $field)) : strlen($value);
        $minLength = $field->getMinLength();
        $maxLength = NumberUtils::bound($field->getMaxLength(), $minLength, $this->getMaxBytes());
        $okay = $length >= $minLength && $length <= $maxLength;

        Assertion::true(
            $okay,
            sprintf(
                'Field [%s] must be between [%d] and [%d] bytes, [%d] bytes given.',
                $field->getName(),
                $minLength,
                $maxLength,
                $length
            ),
            $field->getName()
        );
    }
public function guard ( $ value , Field $ field ) { Assertion :: string ( $ value , null , $ field -> getName ( ) ) ; // intentionally using strlen to get byte length, not mb_strlen $ length = $ this -> encodeToBase64 ? strlen ( $ this -> encode ( $ value , $ field ) ) : strlen ( $ value ) ; $ minLength = $ field -> getMinLength ( ) ; $ maxLength = NumberUtils :: bound ( $ field -> getMaxLength ( ) , $ minLength , $ this -> getMaxBytes ( ) ) ; $ okay = $ length >= $ minLength && $ length <= $ maxLength ; Assertion :: true ( $ okay , sprintf ( 'Field [%s] must be between [%d] and [%d] bytes, [%d] bytes given.' , $ field -> getName ( ) , $ minLength , $ maxLength , $ length ) , $ field -> getName ( ) ) ; }
{@inheritdoc}
{