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

ObjectField({ required: false, nullable: true }) doesn't actually allow null/undefined values unless cast is overridden #10928

Closed
JPMeehan opened this issue May 15, 2024 · 1 comment
Assignees
Labels
bug Functionality which is not working as intended data-models Issues related to data models and schema changes

Comments

@JPMeehan
Copy link

JPMeehan commented May 15, 2024

ObjectField#_cast will transform any null or undefined values into {} even if required: false is set. One example of this is the AdditionalTypesField that's used in BaseModule and as of v12, BaseSystem.

I'm good with the defaults, but maybe _cast should be updated to account for this options or a note should be made that downstream developers should also implement their own _cast method.

@JPMeehan JPMeehan changed the title ObjectField({ required: false }) doesn't actually allow null/undefined values unless cast is overridden ObjectField({ required: false, nullable: true }) doesn't actually allow null/undefined values unless cast is overridden May 15, 2024
@aaclayton aaclayton added bug Functionality which is not working as intended data-models Issues related to data models and schema changes labels May 16, 2024
@aaclayton aaclayton self-assigned this May 20, 2024
@aaclayton aaclayton added this to the V12 Stable 1 milestone May 20, 2024
@aaclayton
Copy link
Contributor

Pushed a fix to ObjectField which allows it to be initialized as undefined in cases where {required: false} or initialized as null in cases where {required: true, nullable: true}, otherwise initialized as an empty object {}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality which is not working as intended data-models Issues related to data models and schema changes
Projects
Status: Done
Development

No branches or pull requests

2 participants