Repository navigation
Conversation
The tests import valigo, and valigo is going to import timex for the rules of tags: an internal test package would be an import cycle. SetNow of export_test.go replaces the current time.
Configurator.Tags("validate") configures the rules of the tags of the
fields of the struct and of its nested structs, validate:"required,max=64",
by the rules of valigo with their messages, codes and constraints: the
rules of strings, numbers, bools, times, the lengths of slices and maps,
dive into the elements and the values of map[string]V, unique, the rules
on other fields, omitempty. The rules of the fields of a nil nested
struct are skipped, like by go-playground/validator. An unknown rule
panics in Configure. shared.InStruct reports whether the nested structs
of a field are present.
Contributor
Benchmark diff:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #72 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 37 38 +1
Lines 1250 1471 +221
==========================================
+ Hits 1250 1471 +221 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or 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
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.
b.Tags("validate")inConfigureapplies the tags of go-playground/validator as the rules of valigo, for a migration: the structs keep their tags, the rules move to code one by one, tags and code are mixed in oneConfigure.oneof, formats,startswith...,datetime,eqfield), numbers of all kinds (min/gte,max/lte,eq,oneof,latitude,gtefield...),bool,time.Time(gtfield,ltfield), lengths of slices and maps,unique,diveinto elements and values ofmap[string]V,omitempty,requiredof nested struct pointers.shared.InStruct) — the optional address with a required city keeps working after the migration.|,keys,diveinto structs,uniqueof pointer slices panic inConfigurewith the field and the reason: a typo isn't a missing check.test(timex): the tests moved totimex_test, valigo imports timex now. Docs: Configuration → Rules from tags with the table of the rules and the differences from go-playground/validator; the roadmap item of the README is done. 100% coverage.