Permalink
Browse files

Validate MinMax Nested Changeset (#34)

* handling validate min max nested changeset

* add new line in gitignore
  • Loading branch information...
kinto-d authored and Fs02 committed Oct 8, 2018
1 parent 25e6437 commit 4b3f0f15666735051c5cc0f2444a02abb205d964
Showing with 9 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +2 −0 changeset/validate_max.go
  3. +2 −0 changeset/validate_max_test.go
  4. +2 −0 changeset/validate_min.go
  5. +2 −0 changeset/validate_min_test.go
@@ -4,3 +4,4 @@ coverage.out
*.db
.vscode/
debug.test
.idea/
@@ -28,6 +28,8 @@ func ValidateMax(ch *Changeset, field string, max int, opts ...Option) {
invalid = len(v) > max
case []interface{}:
invalid = len(v) > max
case []*Changeset:
invalid = len(v) > max
case int:
invalid = v > max
case int8:
@@ -12,6 +12,7 @@ func TestValidateMax(t *testing.T) {
"long text",
10,
[]interface{}{"a", "b", "c", "d", "e", "f"},
[]*Changeset{{}, {}, {}, {}, {}, {}},
int8(10),
int16(10),
int32(10),
@@ -45,6 +46,7 @@ func TestValidateMax_error(t *testing.T) {
"long text",
10,
[]interface{}{"a", "b", "c", "d", "e", "f"},
[]*Changeset{{}, {}, {}, {}, {}, {}},
int8(10),
int16(10),
int32(10),
@@ -28,6 +28,8 @@ func ValidateMin(ch *Changeset, field string, min int, opts ...Option) {
invalid = len(v) < min
case []interface{}:
invalid = len(v) < min
case []*Changeset:
invalid = len(v) < min
case int:
invalid = v < min
case int8:
@@ -12,6 +12,7 @@ func TestValidateMin(t *testing.T) {
"long text",
10,
[]interface{}{"a", "b", "c", "d", "e", "f"},
[]*Changeset{{}, {}, {}, {}, {}, {}},
int8(10),
int16(10),
int32(10),
@@ -45,6 +46,7 @@ func TestValidateMin_error(t *testing.T) {
"long text",
10,
[]interface{}{"a", "b", "c", "d", "e", "f"},
[]*Changeset{{}, {}, {}, {}, {}, {}},
int8(10),
int16(10),
int32(10),

0 comments on commit 4b3f0f1

Please sign in to comment.