-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fix Seq Validation #219
Fix Seq Validation #219
Conversation
|
||
import com.spotify.elitzur.{DataInvalidException, IllegalValidationException, MetricsReporter} | ||
import java.lang.{StringBuilder => JStringBuilder} | ||
import com.spotify.elitzur.{ |
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.
Sorry, running scalafmt on this made it seem like a much larger change. The material changes are in SeqLikeValidator
(line 184), validationLoop
(line 327), and validateField
(line 424)
@@ -0,0 +1,207 @@ | |||
package com.spotify.elitzur.validators |
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.
I think some of our core tests got dropped when we open sourced. Adding some simple testing here so we aren't relying on ValidatorDoFnTest as much
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.
Hard to parse the details with the scalafmt changes but looks intuitive to me
@@ -125,6 +125,7 @@ object CaseClassValidators { | |||
val fiveNFiveVal: Validator[FiveNestedFiveFields] = genFiveNestedFive() | |||
} | |||
|
|||
//scalastyle:off magic.number |
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.
Need a correspond on toggle
The current approach to Seq validation fails on Seqs containing nested records when it tries to get the ValidationType name from the nested record. It needs the ValidationType name in order to publish metrics. To avoid this problem this splits the field level validation logic into its own function that writes the metrics. This can then be re-used from
DerivedValidator
andSeqLikeValidator
against anyFieldValidator
I benchmarked this against master and there was no performance degradation (it was actually a bit faster but might just be variance)