예제 #1
0
// Pattern validates a string against a regular expression
func Pattern(path, in, data, pattern string) *errors.Validation {
	re := regexp.MustCompile(pattern)
	if !re.MatchString(data) {
		return errors.FailedPattern(path, in, pattern)
	}
	return nil
}
예제 #2
0
func patternFail(param *spec.Parameter) *errors.Validation {
	return errors.FailedPattern(param.Name, param.In, param.Pattern)
}
예제 #3
0
func patternFailItems(path, in string, items *spec.Items) *errors.Validation {
	return errors.FailedPattern(path, in, items.Pattern)
}