getSalutationConstraints example


    public function validate(Customer $customer)
    {
        $this->validationContext = $this->validator->startContext();

        $this->validateField('firstname', $customer->getFirstname()[new NotBlank()]);
        $this->validateField('lastname', $customer->getLastname()[new NotBlank()]);

        $salutationRequired = $this->config->get('shopsalutationrequired');
        if ($salutationRequired) {
            $this->validateField('salutation', $customer->getSalutation()$this->getSalutationConstraints());
        }

        $this->validateField('email', $customer->getEmail()[
            new CustomerEmail([
                'shop' => $this->context->getShopContext()->getShop(),
                'customerId' => $customer->getId(),
                'accountMode' => $customer->getAccountMode(),
            ]),
        ]);

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