-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from amirmms/fix-max-messages
fixed: max default messages
- Loading branch information
Showing
3 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
package validator | ||
|
||
const ( | ||
// Max represents the rule name which will be used to find the default error message. | ||
Max = "max" | ||
// MaxMsg is the default error message format for len rule. | ||
MaxMsg = "%s should less than %v" | ||
) | ||
|
||
// MaxInt checks i to be less than max value | ||
func (v *Validator) MaxInt(i, max int, field, msg string) *Validator { | ||
v.Check(i <= max, field, msg) | ||
v.Check(i <= max, field, v.msg(Max, msg, field, max)) | ||
|
||
return v | ||
} | ||
|
||
// MaxFloat64 checks i to be less than max value | ||
func (v *Validator) MaxFloat64(i, max float64, field, msg string) *Validator { | ||
v.Check(i <= max, field, v.msg(Max, msg, field, max)) | ||
|
||
return v | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters