dataModelValidator->isBytesObject($value)) { $context->addViolation('Expected bytes object.', 'invalid_bytes'); return $value; } $encoded = $value['$bytes']; if (!\is_string($encoded)) { $context->addViolation('Expected bytes object.', 'invalid_bytes'); return $value; } $bytes = \base64_decode($encoded, TRUE); $length = \is_string($bytes) ? \strlen($bytes) : 0; if ($this->minLength !== NULL && $length < $this->minLength) { $context->addViolation(\sprintf('Expected at least %d bytes.', $this->minLength), 'min_length'); } if ($this->maxLength !== NULL && $length > $this->maxLength) { $context->addViolation(\sprintf('Expected at most %d bytes.', $this->maxLength), 'max_length'); } return $value; } }