Skip to content

Commit

Permalink
Merge pull request #69 from rezakhademix/better-args-sequence-in-date…
Browse files Browse the repository at this point in the history
…-method

updated: date method for better args
  • Loading branch information
rezakhademix authored Mar 11, 2024
2 parents 415be18 + 88b87ee commit 92c45c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions date.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const (
DateMsg = "%s has wrong date format"
)

// Date checks the value under validation to be a valid, non-relative date.
// Date checks the value under validation to be a valid, non-relative date with give layout.
//
// Example:
//
// govalidator.Date("2024-03-09", "2006-01-02", "birthdate", "birthdate must be a valid date in the format YYYY-MM-DD.")
func (v *Validator) Date(d, layout, field, msg string) *Validator {
// govalidator.Date("2006-01-02", "2024-03-09","birthdate", "birthdate must be a valid date in the format YYYY-MM-DD.")
func (v *Validator) Date(layout, d, field, msg string) *Validator {
_, err := time.Parse(layout, d)
if err != nil {
v.Check(false, field, v.msg(Date, msg, field))
Expand Down
2 changes: 1 addition & 1 deletion date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func Test_Date(t *testing.T) {
v := New()

for _, test := range tests {
v.Date(test.value, test.layout, test.field, test.msg)
v.Date(test.layout, test.value, test.field, test.msg)

if !test.isPassed {
assert.Equalf(
Expand Down

0 comments on commit 92c45c9

Please sign in to comment.