Exemplo n.º 1
0
/*
 * userdata用バリテータ
 */
func UserValidate(user User) error {
	Validator := valval.Object(valval.M{
		"Name": valval.String(
			valval.MaxLength(50),
		),
		"description": valval.String(
			valval.MaxLength(10000),
		),
	})
	return Validator.Validate(user)
}
Exemplo n.º 2
0
func UserValidate(user User) error {
	Validator := valval.Object(valval.M{
		"Name": valval.String(
			valval.MaxLength(20),
			valval.Regexp(regexp.MustCompile(`^[a-z ]+$`)),
		),
	})

	return Validator.Validate(user)
}
Exemplo n.º 3
0
func ArticleValidate(article Article) error {
	Validator := valval.Object(valval.M{
		"Name": valval.String(
			valval.MaxLength(20),
			valval.Regexp(regexp.MustCompile(`^[a-z ]+$`)),
		),
	})

	return Validator.Validate(article)
}
Exemplo n.º 4
0
package gen

import (
	"github.com/wcl48/valval"
	"regexp"
)

var _ = valval.String
var _ = regexp.Compile

var HogePostValidator = valval.Object(valval.M{
	"Name": valval.String(),
	"Code": valval.String(
		valval.MinLength(8),
		valval.MaxLength(16),
		valval.Regexp(regexp.MustCompile(`^[a-z0-9]+$`)),
	),
	"Email": valval.String(
		validateEmail,
	),
	"Password": valval.String(
		valval.Regexp(regexp.MustCompile(`^[a-zA-Z0-9_]$`)),
	),
	"StringArraySample": valval.Slice(
		valval.String(
			valval.MinLength(1),
			valval.MaxLength(50),
			validateEmail,
		),
	).Self(
		valval.MinSliceLength(1),