public function getValidator(PermissionInterface $permission)
    {
        /** @var ValidatorInterface|null $validator */
        $validator = $this->validatorPluginManager->get($permission->getValidator());

        if (!$validator) {
            throw new Exception\ValidatorNotFound(sprintf(
                'The validator \"%s\" could not be found',
                is_object($validator) ? get_class($validator) : gettype($validator)
            ));
        }

        if ($permission->getValidatorOptions()) {
            $json = $permission->getValidatorOptions();
            $options = json_decode($json, true);

            if (!$options) {
                throw new Exception\RuntimeException(sprintf(
                    'The options for validator \"%s\" must be in json format',
                    is_object($validator) ? get_class($validator) : gettype($validator)
                ));
            }

            foreach ($options as $method => $value) {
                $validator->{$method}($value);
            }
        }

        return $validator;
    }