Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api-model): correct AllOptionalMetaclass for field validation in form models #1924

Merged

Conversation

laurent-laporte-pro
Copy link
Contributor

The goal of this PR is to correct the implementation of the AllOptionalMetaclass metaclass used to implement Pydantic models for reading and updating configuration data (short-term storage, thermal clusters, renewable resources clusters, etc.).

The metaclass has been fixed to allow field validation when they come from an ancestor class to the model (using inheritance).

The use_none option has been added to the metaclass parameters to indicate that we want to use the None value instead of the default values. This is necessary, for example, to update certain fields of a model while leaving other fields unchanged: the None value is used to indicate the fields that we wants to preserve.

Unit tests have been corrected to take into consideration the form field validation (previously, validation was not occurring).

Minor changes have been made to correct the documentation and reorganize/fix module imports.

@laurent-laporte-pro laurent-laporte-pro merged commit d11b7a5 into dev Feb 5, 2024
6 checks passed
@laurent-laporte-pro laurent-laporte-pro deleted the bugfix/ensure-validation-in-AllOptionalMetaclass branch February 5, 2024 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants