Skip to content

Commit

Permalink
Fix typos and remove duplicated words in comments (#1100)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear authored Apr 29, 2023
1 parent ba7d9ec commit e6fb514
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion baked_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Func func(fl FieldLevel) bool
// validation needs. The return value should be true when validation succeeds.
type FuncCtx func(ctx context.Context, fl FieldLevel) bool

// wrapFunc wraps noramal Func makes it compatible with FuncCtx
// wrapFunc wraps normal Func makes it compatible with FuncCtx
func wrapFunc(fn Func) FuncCtx {
if fn == nil {
return nil // be sure not to wrap a bad function.
Expand Down
10 changes: 5 additions & 5 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ use the UTF-8 hex representation 0x7C, which is replaced in the code as a pipe,
so the above will become excludesall=0x7C
type Test struct {
Field `validate:"excludesall=|"` // BAD! Do not include a a pipe!
Field `validate:"excludesall=|"` // BAD! Do not include a pipe!
Field `validate:"excludesall=0x7C"` // GOOD! Use the UTF-8 hex representation.
}
Expand Down Expand Up @@ -239,7 +239,7 @@ Example #2
map[[2]string]string with validation tag "gt=0,dive,keys,dive,eq=1|eq=2,endkeys,required"
// gt=0 will be applied to the map itself
// eq=1|eq=2 will be applied to each array element in the the map keys
// eq=1|eq=2 will be applied to each array element in the map keys
// required will be applied to map values
# Required
Expand Down Expand Up @@ -916,7 +916,7 @@ this with the omitempty tag.
# Base64URL String
This validates that a string value contains a valid base64 URL safe value
according the the RFC4648 spec.
according the RFC4648 spec.
Although an empty string is a valid base64 URL safe value, this will report
an empty string as an error, if you wish to accept an empty string as valid
you can use this with the omitempty tag.
Expand All @@ -927,7 +927,7 @@ you can use this with the omitempty tag.
# Base64RawURL String
This validates that a string value contains a valid base64 URL safe value,
but without = padding, according the the RFC4648 spec, section 3.2.
but without = padding, according the RFC4648 spec, section 3.2.
Although an empty string is a valid base64 URL safe value, this will report
an empty string as an error, if you wish to accept an empty string as valid
you can use this with the omitempty tag.
Expand Down Expand Up @@ -1361,7 +1361,7 @@ More information on https://cve.mitre.org/
# Credit Card
This validates that a string value contains a valid credit card number using Luhn algoritm.
This validates that a string value contains a valid credit card number using Luhn algorithm.
Usage: credit_card
Expand Down
6 changes: 3 additions & 3 deletions struct_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type StructLevel interface {
// existing namespace that validator is on.
// e.g. pass 'User.FirstName' or 'Users[0].FirstName' depending
// on the nesting. most of the time they will be blank, unless you validate
// at a level lower the the current field depth
// at a level lower the current field depth
ReportValidationErrors(relativeNamespace, relativeActualNamespace string, errs ValidationErrors)
}

Expand All @@ -74,7 +74,7 @@ var _ StructLevel = new(validate)
// if not is a nested struct.
//
// this is only called when within Struct and Field Level validation and
// should not be relied upon for an acurate value otherwise.
// should not be relied upon for an accurate value otherwise.
func (v *validate) Top() reflect.Value {
return v.top
}
Expand All @@ -85,7 +85,7 @@ func (v *validate) Top() reflect.Value {
// if not is a nested struct.
//
// this is only called when within Struct and Field Level validation and
// should not be relied upon for an acurate value otherwise.
// should not be relied upon for an accurate value otherwise.
func (v *validate) Parent() reflect.Value {
return v.slflParent
}
Expand Down
2 changes: 1 addition & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func asInt(param string) int64 {
func asIntFromTimeDuration(param string) int64 {
d, err := time.ParseDuration(param)
if err != nil {
// attempt parsing as an an integer assuming nanosecond precision
// attempt parsing as an integer assuming nanosecond precision
return asInt(param)
}
return int64(d)
Expand Down
8 changes: 4 additions & 4 deletions validator_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var (

// FilterFunc is the type used to filter fields using
// StructFiltered(...) function.
// returning true results in the field being filtered/skiped from
// returning true results in the field being filtered/skipped from
// validation
type FilterFunc func(ns []byte) bool

Expand Down Expand Up @@ -153,7 +153,7 @@ func (v *Validate) SetTagName(name string) {
}

// ValidateMapCtx validates a map using a map of validation rules and allows passing of contextual
// validation validation information via context.Context.
// validation information via context.Context.
func (v Validate) ValidateMapCtx(ctx context.Context, data map[string]interface{}, rules map[string]interface{}) map[string]interface{} {
errs := make(map[string]interface{})
for field, rule := range rules {
Expand Down Expand Up @@ -453,7 +453,7 @@ func (v *Validate) StructPartial(s interface{}, fields ...string) error {
}

// StructPartialCtx validates the fields passed in only, ignoring all others and allows passing of contextual
// validation validation information via context.Context
// validation information via context.Context
// Fields may be provided in a namespaced fashion relative to the struct provided
// eg. NestedStruct.Field or NestedArrayField[0].Struct.Name
//
Expand Down Expand Up @@ -543,7 +543,7 @@ func (v *Validate) StructExcept(s interface{}, fields ...string) error {
}

// StructExceptCtx validates all fields except the ones passed in and allows passing of contextual
// validation validation information via context.Context
// validation information via context.Context
// Fields may be provided in a namespaced fashion relative to the struct provided
// i.e. NestedStruct.Field or NestedArrayField[0].Struct.Name
//
Expand Down
8 changes: 4 additions & 4 deletions validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9319,11 +9319,11 @@ func TestStructFiltered(t *testing.T) {
errs = validate.StructFiltered(tPartial, p2)
Equal(t, errs, nil)

// this isn't really a robust test, but is ment to illustrate the ANON CASE below
// this isn't really a robust test, but is meant to illustrate the ANON CASE below
errs = validate.StructFiltered(tPartial.SubSlice[0], p3)
Equal(t, errs, nil)

// mod tParial for required feild and re-test making sure invalid fields are NOT required:
// mod tParial for required field and re-test making sure invalid fields are NOT required:
tPartial.Required = ""

// inversion and retesting Partial to generate failures:
Expand All @@ -9339,7 +9339,7 @@ func TestStructFiltered(t *testing.T) {
errs = validate.StructFiltered(tPartial, p1)
Equal(t, errs, nil)

// will fail as unset feild is tested
// will fail as unset field is tested
errs = validate.StructFiltered(tPartial, p2)
NotEqual(t, errs, nil)
AssertError(t, errs, "TestPartial.Anonymous.A", "TestPartial.Anonymous.A", "A", "A", "required")
Expand Down Expand Up @@ -9368,7 +9368,7 @@ func TestStructFiltered(t *testing.T) {
Equal(t, len(errs.(ValidationErrors)), 1)
AssertError(t, errs, "TestPartial.SubSlice[0].Test", "TestPartial.SubSlice[0].Test", "Test", "Test", "required")

// reset struct in slice, and unset struct in slice in unset posistion
// reset struct in slice, and unset struct in slice in unset position
tPartial.SubSlice[0].Test = "Required"

// these will pass as the unset item is NOT tested
Expand Down

0 comments on commit e6fb514

Please sign in to comment.