-
Notifications
You must be signed in to change notification settings - Fork 11
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
Support Extra data models and subforms in validation #730
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… various tests and minor issues
ivarne
force-pushed
the
feat/multi-data-model-with-validation
branch
from
August 19, 2024 12:22
c2bfbae
to
f7b91e0
Compare
src/Altinn.App.Core/Features/Validation/Wrappers/DataElementValidatorWrapper.cs
Dismissed
Show dismissed
Hide dismissed
test/Altinn.App.Core.Tests/LayoutExpressions/TestUtilities/DynamicClassBuilderChatGPTTests.cs
Fixed
Show fixed
Hide fixed
test/Altinn.App.Core.Tests/LayoutExpressions/TestUtilities/DynamicClassBuilderChatGPTTests.cs
Dismissed
Show dismissed
Hide dismissed
test/Altinn.App.Core.Tests/LayoutExpressions/TestUtilities/DynamicClassBuilderTests.cs
Dismissed
Show dismissed
Hide dismissed
ivarne
force-pushed
the
feat/multi-data-model-with-validation
branch
from
August 22, 2024 10:05
1703585
to
9007d42
Compare
src/Altinn.App.Core/Internal/Expressions/LayoutEvaluatorStateInitializer.cs
Fixed
Show fixed
Hide fixed
…before CreateAppModelData call
Make expression engine async
Merged
19 tasks
also a few final touches and possible test fixes
* Refactor DataController and separate out DataElementAccessChecker so that it is easier to reuse logic and return consistent ProblemDetails across APIs * Fix error in compatibility code with ActionController not returning data from UpdatedDataModels when IInstanceDataMutator is not used. * Return Instance from UserAction endpoint in case data elements were added or removed. * Check that instance is active when updating metadata. * Use PatchListItem in multiplePatchEndpoint instead of dictionary for better OpenApi documentation
5 tasks
1 task
* use IInstanceMutator * Make IInstanceMutator update dataValues and PresentationTexts and remove from places that uses it
src/Altinn.App.Core/Internal/Data/CachedInstanceDataAccessor.cs
Dismissed
Show dismissed
Hide dismissed
HauklandJ
approved these changes
Oct 10, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, some minor things to consider
src/Altinn.App.Core/Helpers/Serialization/ModelSerializationService.cs
Outdated
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
ivarne
changed the title
Feat/multi data model with validation
Support Extra data models and subforms in validation
Oct 11, 2024
ivarne
added
the
feature
Label Pull requests with new features. Used when generation releasenotes
label
Oct 11, 2024
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Work on supporting multiple data models and subforms in backend validations with expressions.
Related Issue(s)
Main changes
The main goal for this PR is to add
New single interface for validation
IValidator
With changes in one data element affects the validity of another element, the current hierarchy of validators and only
IFormDataValidator
supporting incremental validation break down. Adaptors for the old interfaces has been provided so no changes to current apps are required, but they might want to update in order to support incremental validation and read instance data with theIInstanceDataAccessor
.New interface
IInstanceDataAccessor
When validation has dependencies across data models, we need a cached way to access the content of data elements that does not require us to download the same data element multiple times for the same request. The implementation is not available from DI, but always passed as an argument in order to eliminate risk of it being reused cross requests because of Singleton services or other unintentionally shared global state.
New
DataElementId
struct to ensure type safety for a wrapped Guid36 places in the updated code need to reference the Guid of a data element, and adding type safety is an important step to ensure correctness. An implicit cast is provided from
DataElement
to simplify usageNew
ModelBinding
struct in expressions engineTo support the new syntax for referring to a non default data element in components and expressions
When handling references to a specific fields (eg. for removal) we needed to also add
DataReference
to combine a Field (path) with a specific DataElementIdNew PATCH api endpoint that allows frontend to update multiple data models at the same time
Saving and triggering incremental validation is expensive and some apps might want to batch multiple changes to reduce cost. The code in frontend would also be simplified if it could do a single request, instead of multiple.
ValidationIssueWithSource
class for external apisPreviously we had a single class
ValidationIssue
that included aSource
property. Service owners sometimes tries to set this in their validators (because it shows up in intellisense), but as we override it based onIValidator.ValidationSource
in ourValidationService
it would be good if it wasn't there to confuse. This PR creates a new typeValidationIssueWithSource
for external apis (where the source is included) and marks it[Obsolete]
in the type returned in the validator interfaces.Respect new app logic settings for data elements
DisallowUserCreate
andDisallowUserDelete
This means that users can not create or delete this types. Typically used for prefill, when you want only the org token to be able to modify the number of data elements on an instance.
Minor changes
Used IL code to generate real C# classes based on the json data models in shared tests. Previously different code was used to access properties of the test code as in production, which is not really good for tests.
Verification
Documentation