Skip to content

Commit cc2da63

Browse files
committed
chore: Fixing go fmt
1 parent 43dbba3 commit cc2da63

File tree

4 files changed

+34
-32
lines changed

4 files changed

+34
-32
lines changed

date.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ type DateRule struct {
2525
// Date returns a validation rule that checks if a string value is in a format that can be parsed into a date.
2626
// The format of the date should be specified as the layout parameter which accepts the same value as that for time.Parse.
2727
// For example,
28-
// validation.Date(time.ANSIC)
29-
// validation.Date("02 Jan 06 15:04 MST")
30-
// validation.Date("2006-01-02")
28+
//
29+
// validation.Date(time.ANSIC)
30+
// validation.Date("02 Jan 06 15:04 MST")
31+
// validation.Date("2006-01-02")
3132
//
3233
// By calling Min() and/or Max(), you can let the Date rule to check if a parsed date value is within
3334
// the specified date range.

map.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ type (
4141
// Use Key() to specify map keys that need to be validated. Each Key() call specifies a single key which can
4242
// be associated with multiple rules.
4343
// For example,
44-
// validation.Map(
45-
// validation.Key("Name", validation.Required),
46-
// validation.Key("Value", validation.Required, validation.Length(5, 10)),
47-
// )
44+
//
45+
// validation.Map(
46+
// validation.Key("Name", validation.Required),
47+
// validation.Key("Value", validation.Required, validation.Length(5, 10)),
48+
// )
4849
//
4950
// A nil value is considered valid. Use the Required rule to make sure a map value is present.
5051
func Map(keys ...*KeyRules) MapRule {

struct.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ func (e ErrFieldNotFound) Error() string {
4747
// should be specified as a pointer to the field. A field can be associated with multiple rules.
4848
// For example,
4949
//
50-
// value := struct {
51-
// Name string
52-
// Value string
53-
// }{"name", "demo"}
54-
// err := validation.ValidateStruct(&value,
55-
// validation.Field(&a.Name, validation.Required),
56-
// validation.Field(&a.Value, validation.Required, validation.Length(5, 10)),
57-
// )
58-
// fmt.Println(err)
59-
// // Value: the length must be between 5 and 10.
50+
// value := struct {
51+
// Name string
52+
// Value string
53+
// }{"name", "demo"}
54+
// err := validation.ValidateStruct(&value,
55+
// validation.Field(&a.Name, validation.Required),
56+
// validation.Field(&a.Value, validation.Required, validation.Length(5, 10)),
57+
// )
58+
// fmt.Println(err)
59+
// // Value: the length must be between 5 and 10.
6060
//
6161
// An error will be returned if validation fails.
6262
func ValidateStruct(structPtr interface{}, fields ...*FieldRules) error {

validation.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ var (
6060
// Validate validates the given value and returns the validation error, if any.
6161
//
6262
// Validate performs validation using the following steps:
63-
// 1. For each rule, call its `Validate()` to validate the value. Return if any error is found.
64-
// 2. If the value being validated implements `Validatable`, call the value's `Validate()`.
65-
// Return with the validation result.
66-
// 3. If the value being validated is a map/slice/array, and the element type implements `Validatable`,
67-
// for each element call the element value's `Validate()`. Return with the validation result.
63+
// 1. For each rule, call its `Validate()` to validate the value. Return if any error is found.
64+
// 2. If the value being validated implements `Validatable`, call the value's `Validate()`.
65+
// Return with the validation result.
66+
// 3. If the value being validated is a map/slice/array, and the element type implements `Validatable`,
67+
// for each element call the element value's `Validate()`. Return with the validation result.
6868
func Validate(value interface{}, rules ...Rule) error {
6969
for _, rule := range rules {
7070
if s, ok := rule.(skipRule); ok && s.skip {
@@ -103,16 +103,16 @@ func Validate(value interface{}, rules ...Rule) error {
103103
// ValidateWithContext validates the given value with the given context and returns the validation error, if any.
104104
//
105105
// ValidateWithContext performs validation using the following steps:
106-
// 1. For each rule, call its `ValidateWithContext()` to validate the value if the rule implements `RuleWithContext`.
107-
// Otherwise call `Validate()` of the rule. Return if any error is found.
108-
// 2. If the value being validated implements `ValidatableWithContext`, call the value's `ValidateWithContext()`
109-
// and return with the validation result.
110-
// 3. If the value being validated implements `Validatable`, call the value's `Validate()`
111-
// and return with the validation result.
112-
// 4. If the value being validated is a map/slice/array, and the element type implements `ValidatableWithContext`,
113-
// for each element call the element value's `ValidateWithContext()`. Return with the validation result.
114-
// 5. If the value being validated is a map/slice/array, and the element type implements `Validatable`,
115-
// for each element call the element value's `Validate()`. Return with the validation result.
106+
// 1. For each rule, call its `ValidateWithContext()` to validate the value if the rule implements `RuleWithContext`.
107+
// Otherwise call `Validate()` of the rule. Return if any error is found.
108+
// 2. If the value being validated implements `ValidatableWithContext`, call the value's `ValidateWithContext()`
109+
// and return with the validation result.
110+
// 3. If the value being validated implements `Validatable`, call the value's `Validate()`
111+
// and return with the validation result.
112+
// 4. If the value being validated is a map/slice/array, and the element type implements `ValidatableWithContext`,
113+
// for each element call the element value's `ValidateWithContext()`. Return with the validation result.
114+
// 5. If the value being validated is a map/slice/array, and the element type implements `Validatable`,
115+
// for each element call the element value's `Validate()`. Return with the validation result.
116116
func ValidateWithContext(ctx context.Context, value interface{}, rules ...Rule) error {
117117
for _, rule := range rules {
118118
if s, ok := rule.(skipRule); ok && s.skip {

0 commit comments

Comments
 (0)