(t *testing.T)
| 13304 | } |
| 13305 | |
| 13306 | func TestAbilityToValidateNils(t *testing.T) { |
| 13307 | type TestStruct struct { |
| 13308 | Test *string `validate:"nil"` |
| 13309 | } |
| 13310 | |
| 13311 | ts := TestStruct{} |
| 13312 | val := New() |
| 13313 | fn := func(fl FieldLevel) bool { |
| 13314 | return fl.Field().Kind() == reflect.Ptr && fl.Field().IsNil() |
| 13315 | } |
| 13316 | |
| 13317 | err := val.RegisterValidation("nil", fn, true) |
| 13318 | Equal(t, err, nil) |
| 13319 | |
| 13320 | errs := val.Struct(ts) |
| 13321 | Equal(t, errs, nil) |
| 13322 | |
| 13323 | str := "string" |
| 13324 | ts.Test = &str |
| 13325 | |
| 13326 | errs = val.Struct(ts) |
| 13327 | NotEqual(t, errs, nil) |
| 13328 | } |
| 13329 | |
| 13330 | func TestRequiredWithoutPointers(t *testing.T) { |
| 13331 | type Lookup struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…