Skip to content

Commit

Permalink
validation
Browse files Browse the repository at this point in the history
  • Loading branch information
iesreza committed Jul 25, 2024
1 parent 8c8acce commit 2efeac7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/validation/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ func enumValidator(match []string, value *generic.Value, stmt *gorm.Statement, f
}

func afterValidator(match []string, value *generic.Value, stmt *gorm.Statement, field *schema.Field) error {
if value.String() == "" {
var t = value.String()
if t == "" || strings.HasPrefix("0000-00-00", t) {
return nil
}
var srcVal, err = value.Time()
Expand All @@ -98,7 +99,8 @@ func afterValidator(match []string, value *generic.Value, stmt *gorm.Statement,
}

func beforeValidator(match []string, value *generic.Value, stmt *gorm.Statement, field *schema.Field) error {
if value.String() == "" {
var t = value.String()
if t == "" || strings.HasPrefix("0000-00-00", t) {
return nil
}
var srcVal, err = value.Time()
Expand Down Expand Up @@ -460,9 +462,8 @@ func regexValidator(match []string, value *generic.Value) error {
}

func dateValidator(match []string, value *generic.Value) error {
var v = value.String()
fmt.Println(v)
if v == "" {
var t = value.String()
if t == "" || strings.HasPrefix("0000-00-00", t) {
return nil
}
_, err := value.Time()
Expand Down

0 comments on commit 2efeac7

Please sign in to comment.