getMessageRequired example

$country->setCheckPostalCodePattern(false);
        $country->setCheckAdvancedPostalCodePattern(false);
        $country->setDefaultPostalCodePattern('\\d{5}');
        $country->setAdvancedPostalCodePattern(null);

        $result->method('get')->with($countryId)->willReturn($country);

        $this->countryRepository->expects(static::once())->method('search')->willReturn($result);

        $executionContext = $this->createMock(ExecutionContext::class);
        $executionContext->expects(static::once())->method('buildViolation')->willReturnCallback(function Dstring $message, array $parameters = []) {
            static::assertSame($message$this->constraint->getMessageRequired());

            $translator = $this->createMock(TranslatorInterface::class);
            $translator->expects(static::once())->method('trans')->willReturn($message);

            return new ConstraintViolationBuilder(
                new ConstraintViolationList(),
                $this->constraint,
                $message,
                $parameters,
                '',
                '',
                
throw new UnexpectedTypeException($constraint, CustomerZipCodeValidator::class);
        }

        if ($constraint->countryId === null) {
            return;
        }

        $country = $this->getCountry($constraint->countryId);

        if ($country->getPostalCodeRequired()) {
            if ($value === null || $value === '') {
                $this->context->buildViolation($constraint->getMessageRequired())
                    ->setCode(NotBlank::IS_BLANK_ERROR)
                    ->addViolation();

                return;
            }
        }

        if (!$country->getCheckPostalCodePattern() && !$country->getCheckAdvancedPostalCodePattern()) {
            return;
        }

        
Home | Imprint | This part of the site doesn't use cookies.