Merge pull request #443 from kszafran/patch-1
Fix typos
Dean Karn authored 5 years ago
GitHub committed 5 years ago
8 | 8 | type StructLevelFunc func(sl StructLevel) |
9 | 9 | |
10 | 10 | // StructLevelFuncCtx accepts all values needed for struct level validation |
11 | // but also allows passing of contextual validation information vi context.Context. | |
11 | // but also allows passing of contextual validation information via context.Context. | |
12 | 12 | type StructLevelFuncCtx func(ctx context.Context, sl StructLevel) |
13 | 13 | |
14 | // wrapStructLevelFunc wraps noramal StructLevelFunc makes it compatible with StructLevelFuncCtx | |
14 | // wrapStructLevelFunc wraps normal StructLevelFunc makes it compatible with StructLevelFuncCtx | |
15 | 15 | func wrapStructLevelFunc(fn StructLevelFunc) StructLevelFuncCtx { |
16 | 16 | return func(ctx context.Context, sl StructLevel) { |
17 | 17 | fn(sl) |
22 | 22 | // to validate a struct |
23 | 23 | type StructLevel interface { |
24 | 24 | |
25 | // returns the main validation object, in case one want to call validations internally. | |
26 | // this is so you don;t have to use anonymous functoins to get access to the validate | |
25 | // returns the main validation object, in case one wants to call validations internally. | |
26 | // this is so you don't have to use anonymous functions to get access to the validate | |
27 | 27 | // instance. |
28 | 28 | Validator() *Validate |
29 | 29 | |
38 | 38 | |
39 | 39 | // ExtractType gets the actual underlying type of field value. |
40 | 40 | // It will dive into pointers, customTypes and return you the |
41 | // underlying value and it's kind. | |
41 | // underlying value and its kind. | |
42 | 42 | ExtractType(field reflect.Value) (value reflect.Value, kind reflect.Kind, nullable bool) |
43 | 43 | |
44 | 44 | // reports an error just by passing the field and tag information |
46 | 46 | // NOTES: |
47 | 47 | // |
48 | 48 | // fieldName and altName get appended to the existing namespace that |
49 | // validator is on. eg. pass 'FirstName' or 'Names[0]' depending | |
49 | // validator is on. e.g. pass 'FirstName' or 'Names[0]' depending | |
50 | 50 | // on the nesting |
51 | 51 | // |
52 | 52 | // tag can be an existing validation tag or just something you make up |
59 | 59 | // |
60 | 60 | // relativeNamespace and relativeActualNamespace get appended to the |
61 | 61 | // existing namespace that validator is on. |
62 | // eg. pass 'User.FirstName' or 'Users[0].FirstName' depending | |
62 | // e.g. pass 'User.FirstName' or 'Users[0].FirstName' depending | |
63 | 63 | // on the nesting. most of the time they will be blank, unless you validate |
64 | 64 | // at a level lower the the current field depth |
65 | 65 | ReportValidationErrors(relativeNamespace, relativeActualNamespace string, errs ValidationErrors) |