- Issue created by @jwilson3
Countries that have no concept of a state or province, a.k.a. "Administrative Area", fail Entity validation when Country and State fields are marked required on Address field configuration.
1. We have a REST resource for allowing account creation from federated headless subsites, to a main Drupal website, where user accounts are housed. User accounts have an Address field with Country and State (i.e., administrative_area) fields required.
2. User registers on the subsite and selects Sweden for country. The "State" field is either removed or disabled.
3. JS submits to /user/register?_format=JSON with the user account information payload, leaving state either as an empty string, or completely absent from the JSON.
4. The REST response is an UnprocessableEntityHttpException, generated from the EntityResourceValidationTrait::validate() function.
Unprocessable Entity: validation failed.
field_address.0.administrative_area: field is required.
Ensure that entity validation of Address fields take into account the selected Country, and adjust the dependent address field validations accordingly. Eg, if administrative_area is supposed to be empty for a given country, do not send a validation error when the value is left empty. Instead, send a validation error when the value is non-empty.
Active
2.1
Code