MCPcopy
hub / github.com/go-playground/validator / StructLevel

Interface StructLevel

struct_level.go:24–67  ·  view source on GitHub ↗

StructLevel contains all the information and helper functions to validate a struct

Source from the content-addressed store, hash-verified

22// StructLevel contains all the information and helper functions
23// to validate a struct
24type StructLevel interface {
25
26 // Validator returns the main validation object, in case one wants to call validations internally.
27 // this is so you don't have to use anonymous functions to get access to the validate
28 // instance.
29 Validator() *Validate
30
31 // Top returns the top level struct, if any
32 Top() reflect.Value
33
34 // Parent returns the current fields parent struct, if any
35 Parent() reflect.Value
36
37 // Current returns the current struct.
38 Current() reflect.Value
39
40 // ExtractType gets the actual underlying type of field value.
41 // It will dive into pointers, customTypes and return you the
42 // underlying value and its kind.
43 ExtractType(field reflect.Value) (value reflect.Value, kind reflect.Kind, nullable bool)
44
45 // ReportError reports an error just by passing the field and tag information
46 //
47 // NOTES:
48 //
49 // fieldName and structFieldName get appended to the existing
50 // namespace that validator is on. e.g. pass 'FirstName' or
51 // 'Names[0]' depending on the nesting
52 //
53 // tag can be an existing validation tag or just something you make up
54 // and process on the flip side it's up to you.
55 ReportError(field interface{}, fieldName, structFieldName string, tag, param string)
56
57 // ReportValidationErrors reports an error just by passing ValidationErrors
58 //
59 // NOTES:
60 //
61 // relativeNamespace and relativeActualNamespace get appended to the
62 // existing namespace that validator is on.
63 // e.g. pass 'User.FirstName' or 'Users[0].FirstName' depending
64 // on the nesting. most of the time they will be blank, unless you validate
65 // at a level lower the current field depth
66 ReportValidationErrors(relativeNamespace, relativeActualNamespace string, errs ValidationErrors)
67}
68
69var _ StructLevel = new(validate)
70

Implementers 1

validatevalidator.go

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…