Skip to content

Commit

Permalink
Merge pull request #1 from kumakichi/has_default_but_no_validate
Browse files Browse the repository at this point in the history
fix argument who has default but given non-default value
  • Loading branch information
morlay authored Mar 28, 2019
2 parents d93a3ff + 35b51e1 commit 4ac8788
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion validator_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (loader *ValidatorLoader) validate(v interface{}) error {
return errors.MissingRequiredFieldError{}
}

if loader.DefaultValue != nil {
if loader.DefaultValue != nil && reflectx.IsEmptyValue(rv) {
err := reflectx.UnmarshalText(rv, loader.DefaultValue)
if err != nil {
return fmt.Errorf("unmarshal default value failed")
Expand Down

0 comments on commit 4ac8788

Please sign in to comment.