Add support for Symfony Country Constraint

Created on 20 August 2023, over 1 year ago
Updated 10 December 2023, 12 months ago

Problem/Motivation

Add support for Symfony Country Constraint

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇨🇳China g089h515r806

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @g089h515r806
  • Status changed to Fixed over 1 year ago
  • 🇨🇳China g089h515r806

    manual test case:
    1) add a Country constraint to field_test, alpha3 uncheck, save it.

    if populate field_test "123456", get an error message.

    if populate field_test "CN", no error message.

    2) if change alpha3 checked,

    if populate field_test "123456", get an error message.

    if populate field_test "CN", get an error message.
    if populate field_test "CHN", no error message.

    Note:
    You need install symfony/intl and PHP's intl extension, to make this constraint works.
    composer require symfony/intl

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed 12 months ago
  • 🇧🇪Belgium oldeb Namur 🇧🇪

    This change broke my D10 upgrade.

    There is a compatibility issue with the address contrib module , in the AddressItem field type they are decraring a "Country" constraint and giving a "availableCountries" option which they collide with this change and provoking the following error :

    Symfony\Component\Validator\Exception\InvalidOptionsException: The options "availableCountries" do not exist in constraint "Drupal\field_validation\Plugin\Validation\Constraint\CountryConstraint". in Symfony\Component\Validator\Constraint->normalizeOptions() (line 180 of /app/vendor/symfony/validator/Constraint.php).

    I think we should find another id for the CountryConstraint.

Production build 0.71.5 2024