-
Notifications
You must be signed in to change notification settings - Fork 40
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
base: master
Are you sure you want to change the base?
adding ValidateOpts #295
Conversation
Can we fix the linter errors in the build pipeline @mfdeveloper508 . Otherwise, this looks good to me. |
returnDetail.go
Outdated
func (rd *ReturnDetail) Validate() error { | ||
func (rd *ReturnDetail) Validate(opts ...*ValidateOpts) error { |
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.
In ACH we passed the ValidateOpts through a file so all records in a file have the same validation overrides.
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.
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
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.
cc @atonks2 thoughts?
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.
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.
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.
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 Report
❗ 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 |
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.
Thanks for starting on this @mfdeveloper508
// SkipAll will disable all validation checks of a File. It has no effect when set on records. | ||
SkipAll bool `json:"skipAll"` |
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.
SkipAll
can be checked inside File.Validate()
to bypass all checks.
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.
exact validation function of record will hit within reader function only
it seems that we should use skipall flag in validation function of record
#212