File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -46,22 +46,23 @@ import (
4646 " github.com/mkafonso/schema/pkg/validator"
4747)
4848
49- func ValidateStringExample () {
50- input := " Luna "
49+ func ValidateEmailExample () {
50+ 5151
5252 // Defining a validation schema
5353 stringValidator := validator.NewStringValidator ().
54- MinLength (5 , " The string must be at least 5 characters long" ). // Sets minimum length constraint
55- MaxLength (50 , " The string must be at most 50 characters long" ) // Sets maximum length constraint
54+ MinLength (5 , " A string deve ter no mínimo 5 caracteres" ). // Sets minimum length constraint
55+ MaxLength (50 , " A string deve ter no máximo 50 caracteres" ). // Sets maximum length constraint
56+ IsEmail (" Formato de email inválido" ) // Validates as an email format
5657
5758 // Validating the input
5859 result := stringValidator.Validate (input)
5960
6061 // Handling validation result
6162 if result.IsValid {
62- fmt.Println (" String validation successful!" ) // Message for successful validation
63+ fmt.Println (" Validation successful!" ) // Message for successful validation
6364 } else {
64- fmt.Println (" String validation error:" , result.Errors ) // Printing validation errors
65+ fmt.Println (" Validation error:" , result.Errors ) // Printing validation errors
6566 }
6667}
6768```
You can’t perform that action at this time.
0 commit comments