1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-10 02:20:19 +00:00

Add some validate functions

This commit is contained in:
miraclesu
2013-07-27 20:40:15 +08:00
parent 0e748c6871
commit f490141217
4 changed files with 150 additions and 0 deletions

View File

@ -144,6 +144,23 @@ func (v *Validation) Base64(str string, key string) *ValidationResult {
return v.apply(Base64{Match{Regexp: base64Pattern}, key}, str)
}
func (v *Validation) Mobile(str string, key string) *ValidationResult {
return v.apply(Mobile{Match{Regexp: mobilePattern}, key}, str)
}
func (v *Validation) Tel(str string, key string) *ValidationResult {
return v.apply(Tel{Match{Regexp: telPattern}, key}, str)
}
func (v *Validation) Phone(str string, key string) *ValidationResult {
return v.apply(Phone{Mobile{Match: Match{Regexp: mobilePattern}},
Tel{Match: Match{Regexp: telPattern}}, key}, str)
}
func (v *Validation) ZipCode(str string, key string) *ValidationResult {
return v.apply(ZipCode{Match{Regexp: zipCodePattern}, key}, str)
}
func (v *Validation) apply(chk Validator, obj interface{}) *ValidationResult {
if chk.IsSatisfied(obj) {
return &ValidationResult{Ok: true}