diff --git a/max_test.go b/max_test.go index b380b4d..e74d56c 100644 --- a/max_test.go +++ b/max_test.go @@ -8,36 +8,36 @@ import ( func TestValidator_MaxInt(t *testing.T) { tests := []struct { - field string - value int - max int - message string - isPassed bool - excpectedMsg string + field string + value int + max int + message string + isPassed bool + expectedMsg string }{ { - field: "t0", - value: 10, - max: 10, - message: "", - isPassed: true, - excpectedMsg: "", + field: "t0", + value: 10, + max: 10, + message: "", + isPassed: true, + expectedMsg: "", }, { - field: "t1", - value: 1, - max: 0, - message: "t1 must be less than 0", - isPassed: false, - excpectedMsg: "t1 must be less than 0", + field: "t1", + value: 1, + max: 0, + message: "t1 must be less than 0", + isPassed: false, + expectedMsg: "t1 must be less than 0", }, { - field: "t2", - value: 122, - max: 20, - message: "t1 must be less than 20", - isPassed: false, - excpectedMsg: "t1 must be less than 20", + field: "t2", + value: 122, + max: 20, + message: "t1 must be less than 20", + isPassed: false, + expectedMsg: "t1 must be less than 20", }, } @@ -49,7 +49,7 @@ func TestValidator_MaxInt(t *testing.T) { assert.Equal(t, test.isPassed, v.IsPassed()) if !test.isPassed { - assert.Equal(t, test.excpectedMsg, v.Errors()[test.field]) + assert.Equal(t, test.expectedMsg, v.Errors()[test.field]) } } } diff --git a/min_test.go b/min_test.go index cae1540..fafeb60 100644 --- a/min_test.go +++ b/min_test.go @@ -8,36 +8,36 @@ import ( func TestValidator_MinInt(t *testing.T) { tests := []struct { - field string - value int - min int - message string - isPassed bool - excpectedMsg string + field string + value int + min int + message string + isPassed bool + expectedMsg string }{ { - field: "t0", - value: 2, - min: 1, - message: "", - isPassed: true, - excpectedMsg: "", + field: "t0", + value: 2, + min: 1, + message: "", + isPassed: true, + expectedMsg: "", }, { - field: "t1", - value: -1, - min: 0, - message: "t1 must be greater than 0", - isPassed: false, - excpectedMsg: "t1 must be greater than 0", + field: "t1", + value: -1, + min: 0, + message: "t1 must be greater than 0", + isPassed: false, + expectedMsg: "t1 must be greater than 0", }, { - field: "t2", - value: 12, - min: 20, - message: "t1 must be greater than 20", - isPassed: false, - excpectedMsg: "t1 must be greater than 20", + field: "t2", + value: 12, + min: 20, + message: "t1 must be greater than 20", + isPassed: false, + expectedMsg: "t1 must be greater than 20", }, } @@ -49,7 +49,7 @@ func TestValidator_MinInt(t *testing.T) { assert.Equal(t, test.isPassed, v.IsPassed()) if !test.isPassed { - assert.Equal(t, test.excpectedMsg, v.Errors()[test.field]) + assert.Equal(t, test.expectedMsg, v.Errors()[test.field]) } } } diff --git a/required.go b/required.go index 82c3346..3f23e9f 100644 --- a/required.go +++ b/required.go @@ -11,14 +11,14 @@ const ( // RequiredString checks if a string value is empty or not. func (v *Validator) RequiredString(s, field string, msg string) *Validator { - v.Check(strings.TrimSpace(s) != "", field, v.msg(Required, field, msg)) + v.Check(strings.TrimSpace(s) != "", field, v.msg(Required, msg, field)) return v } // RequiredInt checks if an integer value is provided or not. func (v *Validator) RequiredInt(i int, field string, msg string) *Validator { - v.Check(i == 0, field, v.msg(Required, field, msg)) + v.Check(i == 0, field, v.msg(Required, msg, field)) return v } diff --git a/required_test.go b/required_test.go index 8039310..3b2e96e 100644 --- a/required_test.go +++ b/required_test.go @@ -8,32 +8,32 @@ import ( func TestValidator_RequiredString(t *testing.T) { tests := []struct { - tag string - value string - message string - isPassed bool - excpectedMsg string + tag string + value string + message string + isPassed bool + expectedMsg string }{ { - tag: "t0", - value: "test 0", - message: "", - isPassed: true, - excpectedMsg: "", + tag: "t0", + value: "test 0", + message: "", + isPassed: true, + expectedMsg: "", }, { - tag: "t1", - value: "", - message: "t1 is required", - isPassed: false, - excpectedMsg: "t1 is required", + tag: "t1", + value: "", + message: "t1 is required", + isPassed: false, + expectedMsg: "t1 is required", }, { - tag: "t2", - value: " ", - message: "t2 is required", - isPassed: false, - excpectedMsg: "t2 is required", + tag: "t2", + value: " ", + message: "t2 is required", + isPassed: false, + expectedMsg: "t2 is required", }, } @@ -44,7 +44,7 @@ func TestValidator_RequiredString(t *testing.T) { assert.Equal(t, test.isPassed, v.IsPassed()) if !test.isPassed { - assert.Equal(t, test.excpectedMsg, v.Errors()[test.tag]) + assert.Equal(t, test.expectedMsg, v.Errors()[test.tag]) } } }