示例#1
0
文件: values.go 项目: gbjk/go-swagger
// MaxLength validates a string for maximum length
func MaxLength(path, in, data string, maxLength int64) *errors.Validation {
	strLen := int64(utf8.RuneCount([]byte(data)))
	if strLen > maxLength {
		return errors.TooLong(path, in, maxLength)
	}
	return nil
}
func maxLengthErrorItems(path, in string, items *spec.Items) *errors.Validation {
	return errors.TooLong(path, in, *items.MaxLength)
}
func maxLengthError(param *spec.Parameter) *errors.Validation {
	return errors.TooLong(param.Name, param.In, *param.MaxLength)
}