Skip to content

Commit 8096e1a

Browse files
committed
Updated comment formatting
1 parent 98a11de commit 8096e1a

11 files changed

+280
-285
lines changed

examples/model/customer.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/mrz1836/go-validate"
1010
)
1111

12-
//Customer is a very basic model showing validation mixed with JSON
12+
// Customer is a very basic model showing validation mixed with JSON
1313
type Customer struct {
1414
Age uint `validation:"min=18" json:"age"`
1515
Balance float32 `validation:"min=0" json:"balance"`
@@ -23,17 +23,17 @@ type Customer struct {
2323
SocialSecurityNumber string `json:"-"`
2424
}
2525

26-
//Valid is a custom method for the model that will run all built-in validations and also run any custom validations
26+
// Valid is a custom method for the model that will run all built-in validations and also run any custom validations
2727
func (c *Customer) Valid() (bool, []validate.ValidationError) {
2828

29-
//Run all validations off the struct configuration
29+
// Run all validations off the struct configuration
3030
_, errs := validate.IsValid(*c)
3131

3232
//
3333
//Customize: errs (you can add/remove your own errs)
3434
//
3535

36-
//Showing use of a public validation method (extra validations outside of the struct built-in validations)
36+
// Showing use of a public validation method (extra validations outside of the struct built-in validations)
3737
ok, err := validate.IsValidSocial(c.SocialSecurityNumber)
3838
if !ok && err != nil {
3939
errs = append(errs, validate.ValidationError{
@@ -42,22 +42,22 @@ func (c *Customer) Valid() (bool, []validate.ValidationError) {
4242
})
4343
}
4444

45-
//Return error if found
45+
// Return error if found
4646
return len(errs) == 0, errs
4747
}
4848

49-
//Add your custom validations
49+
// Add your custom validations
5050
func init() {
5151

52-
//Add your own custom validations
52+
// Add your own custom validations
5353
//
5454
//
5555
}
5656

57-
//main example (just an example of validating a model's data before persisting into a database)
57+
// main example (just an example of validating a model's data before persisting into a database)
5858
func main() {
5959

60-
//Start with some model & data
60+
// Start with some model & data
6161
customer := &Customer{
6262
Age: 21,
6363
Balance: 1.00,
@@ -70,13 +70,13 @@ func main() {
7070
SocialSecurityNumber: "212126768",
7171
}
7272

73-
//Validate the model - Run before saving into database
73+
// Validate the model - Run before saving into database
7474
_, errs := customer.Valid()
7575
if errs != nil {
7676
fmt.Printf("Customer validation failed! %+v", errs)
7777
} else {
7878
fmt.Println("Customer validation succeed!")
7979
}
8080

81-
//customer.Save() //Now save to a database
81+
// customer.Save() // Now save to a database
8282
}

0 commit comments

Comments
 (0)