NoUrl example

return $element;
    }

    /** * Creates a custom no URL text field. * * @param array<string, string> $options */
    protected function createNoUrlField(string $name, string $label, string $defaultValue, array $options = []): NoUrl
    {
        $element = new NoUrl($name);
        $element->fromArray($options);
        $element->setLabel($label);
        $element->setDefaultValue($defaultValue);

        return $element;
    }
}
/** * @throws ValidationException */
    public function validate(User $user)
    {
        $this->validationContext = $this->validator->startContext();

        $this->validateField('username', $user->getUsername()[
            new UserName([
                'userId' => $user->getId(),
            ]),
            new NoUrl(),
        ]);
        $this->validateField('name', $user->getName()[new NotBlank()new NoUrl()]);
        $this->validateField('role', $user->getRole()[new NotBlank()]);
        $this->validateField('email', $user->getEmail()[
            new UserEmail([
                'userId' => $user->getId(),
            ]),
        ]);

        if ($this->validationContext->getViolations()->count()) {
            throw new ValidationException($this->validationContext->getViolations());
        }
Home | Imprint | This part of the site doesn't use cookies.