Skip to content

Conversation

@ygicp
Copy link

@ygicp ygicp commented Apr 14, 2025

Add a Pydantic V2 @model_validator to the existing genai.types.Part model to enforce data integrity.

This validator ensures that exactly one of the specified optional fields (e.g., field_a, field_b, field_c) has a value other than None. If zero or more than one field is set during validation, a ValueError is now raised.

This refactoring improves the robustness of the model by explicitly enforcing the intended single-choice rule.

…lds in class `types.Part`

Add a Pydantic V2 @model_validator to the existing genai.types.Part model to enforce data integrity.

This validator ensures that exactly one of the specified optional fields (e.g., field_a, field_b, field_c) has a value other than None. If zero or more than one field is set during validation, a ValueError is now raised.

This refactoring improves the robustness of the model by explicitly enforcing the intended single-choice rule.
@MarkDaoust MarkDaoust added do not merge Indicates a pull request not ready for merge, due to either quality or timing. and removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels May 5, 2025
@janasangeetha janasangeetha self-assigned this Nov 7, 2025
@janasangeetha janasangeetha added the size:M Code changes between 10-40 lines label Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M Code changes between 10-40 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants