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 (
46
46
" github.com/mkafonso/schema/pkg/validator"
47
47
)
48
48
49
- func ValidateStringExample () {
50
- input := " Luna "
49
+ func ValidateEmailExample () {
50
+
51
51
52
52
// Defining a validation schema
53
53
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
56
57
57
58
// Validating the input
58
59
result := stringValidator.Validate (input)
59
60
60
61
// Handling validation result
61
62
if result.IsValid {
62
- fmt.Println (" String validation successful!" ) // Message for successful validation
63
+ fmt.Println (" Validation successful!" ) // Message for successful validation
63
64
} else {
64
- fmt.Println (" String validation error:" , result.Errors ) // Printing validation errors
65
+ fmt.Println (" Validation error:" , result.Errors ) // Printing validation errors
65
66
}
66
67
}
67
68
```
You can’t perform that action at this time.
0 commit comments