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

Expansion of constructor for Validate in IFileValidator #554

Closed
FTLems opened this issue Apr 3, 2024 · 5 comments
Closed

Expansion of constructor for Validate in IFileValidator #554

FTLems opened this issue Apr 3, 2024 · 5 comments
Labels
kind/feature-request New feature or request

Comments

@FTLems
Copy link

FTLems commented Apr 3, 2024

Description

In my app, I extract data from excel attachment that user has uploaded and validate certain data against modeldata/data.
Could you expand constructor for Validate method in IFileValidator to include data.

image

Additional Information

No response

@FTLems FTLems added the kind/feature-request New feature or request label Apr 3, 2024
@nkylstad nkylstad transferred this issue from Altinn/altinn-studio Apr 4, 2024
@nkylstad nkylstad removed this from Team Studio Apr 4, 2024
@ivarne
Copy link
Member

ivarne commented Apr 4, 2024

I don't think it would make much sense to always fetch the current data model to run file validators, and when we start supporting multiple data models in the same task, it is unclear what data element we should fetch anyway.

The correct approach would be to use IDataClient instead, and just fetch the relevant data you need. Unfortunately the interface does not give you a reference to the Instance the user uploads to, so currently you would need to use IHttpContextAccessor to get the request url, and parse the instance and data guids from there.

Do you like the separation between IFileAnalyzer and IFileValidator, where you need to implement both, or would it be better to just have a single interface with no intermediate FileAnalysisResult?

@FTLems
Copy link
Author

FTLems commented Apr 5, 2024

Hmm... Didn't think of that before. Let me test og come back on it if it works.

No, I do like the separation of FileAnalyse and FileValidator. The code is more clear and follows the single responsibility principle.

@RonnyB71
Copy link
Member

RonnyB71 commented Apr 5, 2024

What is the use case where you need to get the data in addition to the results from the analyzer?

The original thought behind the IFileAnalyzer and IFileValidator separation was to:

  1. Avoid coupling of the two as they have different responsibilities and in some cases you don't want to validate against the file, just analyze it and read out some values to put in the data model.
  2. Being able to run multiple analyzers in sequence and use the combined result for validation. Although this might something that seemed like a good idea in my head at the time:)

@FTLems
Copy link
Author

FTLems commented Apr 5, 2024

This schema is a schema that FT instantiate and dump in the users inbox. The app itself is quite simple, containing information about the report-periode and reportee information. The actual report is this excel-file that they have to attach to the instans (template from this page: excel-template.

We need to do some controll that the excel-file that they are uploading are correct, such as excel-file-versjon number , report periode in excel matches the report periode in datamodel and other controll that the reportee information in excel matches the one that is actual reporting.

@RonnyB71
Copy link
Member

Closing this as the IDataClient can be injected and used to fetch data on the instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature-request New feature or request
Projects
Archived in project
Development

No branches or pull requests

3 participants