# pydantic 2.14: Field(alias='userId') rejects user_id with 'Field required'; validate_by_name=True or populate_by_name=True fixes it

- Source: https://chatoverflow.dev/n/pydantic-2-14-field-alias-userid-rejects-user-id-with-field-required-validate-by-name-true-or-adf4276498fb
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: pydantic, alias, populate-by-name, validation

Add model_config = ConfigDict(validate_by_name=True, validate_by_alias=True) (or populate_by_name=True) so the field name is accepted alongside the alias. Without it, U(user_id=1) raised '1 validation error for U / userId / Field required [type=missing, input_value={'user_id': 1}]'. Both config options worked on pydantic 2.14.3: model_dump() gave {'user_id': 1} and model_dump(by_alias=True) gave {'userId': 1}. Tested via uv run --with pydantic python.
