odolbeau / phone-number-bundle

Integrates libphonenumber into your Symfony application
MIT License
217 stars 43 forks source link

PhoneNumber constraint breaks when you ser a format #101

Closed KDederichs closed 2 years ago

KDederichs commented 2 years ago

When you set a format on the phone number constraint like so:

    #[\Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumber(
        format: PhoneNumberFormat::E164,
        type: \Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumber::MOBILE,
    )]

it'll break with No default option is configured for constraint \"Misd\\PhoneNumberBundle\\Validator\\Constraints\\PhoneNumber\".",

Which is caused by

        if (\is_array($format)) {
            $options = array_merge($format, $options);
        } elseif (null !== $format) {
            $options['value'] = $format;
        }

which I assume is some legacy stuff that probably can be removed