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

adding ValidateOpts #295

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

adding ValidateOpts #295

wants to merge 6 commits into from

Conversation

mfdeveloper508
Copy link
Contributor

@mfdeveloper508 mfdeveloper508 commented May 22, 2023

@wadearnold
Copy link
Member

Can we fix the linter errors in the build pipeline @mfdeveloper508 . Otherwise, this looks good to me.

file.go Outdated Show resolved Hide resolved
file.go Outdated Show resolved Hide resolved
returnDetail.go Outdated
func (rd *ReturnDetail) Validate() error {
func (rd *ReturnDetail) Validate(opts ...*ValidateOpts) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ACH we passed the ValidateOpts through a file so all records in a file have the same validation overrides.

Copy link
Contributor Author

@mfdeveloper508 mfdeveloper508 May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, ACH used above logic
but imagecashletter is different with ACH
Actually we need to hit validation function of ReturnDetail and CheckDetail
Validation function of file doesn't hit these validation functions
The validation functions will hit only when parsing file

I am not sure the reason yet. anyway we should use this parameter for supporting current logic

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @atonks2 thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACH adds an instance of validateOpts to several record types, but then still exposes a ValidateWith method on some of them to pass opts through.

If we add a validateOpts field to each record that has options defined and wire it all the way through from file creation, that would probably cover the most code paths (trying to think through HTTP API vs library). That said, it's not clear to me from a quick review of ACH how the opts get wired through.

@adamdecaf Can you provide more context on how the validate opts work in ACH? How/when are they wired through when using ACH as an API vs a library.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're wired through from the File object so you can accumulate records and the opts are respected during validation. The HTTP api accepts them as a top-level object in JSON.

The ACH library's Reader can also have ValidateOpts which are put onto each file that's read.

@codecov-commenter
Copy link

codecov-commenter commented May 23, 2023

Codecov Report

Merging #295 (fee8d61) into master (e44feff) will decrease coverage by 0.27%.
The diff coverage is 58.13%.

❗ Current head fee8d61 differs from pull request most recent head d15b6ee. Consider uploading reports for the commit d15b6ee to get more accurate results

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #295      +/-   ##
==========================================
- Coverage   87.73%   87.47%   -0.27%     
==========================================
  Files          36       36              
  Lines        5015     5054      +39     
==========================================
+ Hits         4400     4421      +21     
- Misses        406      418      +12     
- Partials      209      215       +6     

Copy link
Collaborator

@atonks2 atonks2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for starting on this @mfdeveloper508

checkDetail.go Outdated Show resolved Hide resolved
cmd/writeImageCashLetter/main.go Outdated Show resolved Hide resolved
file.go Outdated Show resolved Hide resolved
Comment on lines +96 to +97
// SkipAll will disable all validation checks of a File. It has no effect when set on records.
SkipAll bool `json:"skipAll"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SkipAll can be checked inside File.Validate() to bypass all checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exact validation function of record will hit within reader function only
it seems that we should use skipall flag in validation function of record

checkDetail.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants