You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently have a solution in place to enable partial patch, combined with required fields. Users need to add [IsRequired] instead of the built-in [Required] attribute on their resource properties.
Although it works, downsides of this approach are:
Because IsRequired derives from Required, it is picked up by EF Core to generate non-null database columns. But other tools may not recognize it.
At the time that validation logic inside [IsRequired] runs, we have no way to know where in the object graph we are. This is important because on relationship updates, only their IDs are sent, so we must turn off some checks. The way this is implemented now is kinda hacky, but seems to work (even with self-referencing entities in basic scenarios).
The current solution cannot work when we need to validate multiple resources per request (atomic operations).
We currently have a solution in place to enable partial patch, combined with required fields. Users need to add
[IsRequired]
instead of the built-in[Required]
attribute on their resource properties.Although it works, downsides of this approach are:
IsRequired
derives fromRequired
, it is picked up by EF Core to generate non-null database columns. But other tools may not recognize it.[IsRequired]
runs, we have no way to know where in the object graph we are. This is important because on relationship updates, only their IDs are sent, so we must turn off some checks. The way this is implemented now is kinda hacky, but seems to work (even with self-referencing entities in basic scenarios).A quick search made us suspect there's a better way, by interacting with the validation process instead of inventing our own attribute. See https://stackoverflow.com/questions/36982370/is-it-possible-to-use-a-custom-modelstate-validation-provider-in-asp-net-core for details.
This issue tracks the work to deprecate
[IsRequired]
and plug into the ModelState validation process instead.The text was updated successfully, but these errors were encountered: