Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Blank = &DefaultValidationRule{ruleName: "Blank", ruleErrorMsg: "should be blank", ruleFunc: isBlank} NotBlank = &DefaultValidationRule{ruleName: "NotBlank", ruleErrorMsg: "should not be blank", ruleFunc: func(value any) (bool, error) { r, e := isBlank(value) return !r, e }} )
Functions ¶
Types ¶
type DefaultValidationError ¶
type DefaultValidationError struct {
// contains filtered or unexported fields
}
func (*DefaultValidationError) Error ¶
func (v *DefaultValidationError) Error() string
func (*DefaultValidationError) String ¶
func (v *DefaultValidationError) String() string
type DefaultValidationResult ¶
type DefaultValidationResult struct {
// contains filtered or unexported fields
}
func (*DefaultValidationResult) AddError ¶
func (v *DefaultValidationResult) AddError(fieldName, errormsg string) *DefaultValidationResult
func (*DefaultValidationResult) Valid ¶
func (v *DefaultValidationResult) Valid() bool
func (*DefaultValidationResult) ValidationErrors ¶
func (v *DefaultValidationResult) ValidationErrors() []ValidationError
type DefaultValidationRule ¶
type DefaultValidationRule struct {
// contains filtered or unexported fields
}
func (*DefaultValidationRule) RuleErrorMsg ¶
func (r *DefaultValidationRule) RuleErrorMsg() string
func (*DefaultValidationRule) RuleFunc ¶
func (r *DefaultValidationRule) RuleFunc() ValidationFunc
func (*DefaultValidationRule) RuleName ¶
func (r *DefaultValidationRule) RuleName() string
type ValidationBucket ¶
type ValidationBucket struct {
// contains filtered or unexported fields
}
func NewBucket ¶
func NewBucket() *ValidationBucket
func (*ValidationBucket) Error ¶
func (b *ValidationBucket) Error() error
func (*ValidationBucket) ErrorCount ¶
func (b *ValidationBucket) ErrorCount() int
func (*ValidationBucket) IsValid ¶
func (b *ValidationBucket) IsValid() bool
func (*ValidationBucket) Result ¶
func (b *ValidationBucket) Result() ValidationResult
func (*ValidationBucket) Validate ¶
func (b *ValidationBucket) Validate(propName string, value any, vRule ...ValidationRule) (bool, error)
type ValidationError ¶
type ValidationFunc ¶
type ValidationResult ¶
type ValidationResult interface { Valid() bool ValidationErrors() []ValidationError }
type ValidationRule ¶
type ValidationRule interface { RuleName() string RuleFunc() ValidationFunc RuleErrorMsg() string }
func OneOfRule ¶
func OneOfRule(values ...any) ValidationRule
func Range ¶ added in v0.3.1
func Range[K constraints.Ordered](from K, to K) ValidationRule
Range returns a validation rule that checks if the value is within the range.
func RegExRule ¶
func RegExRule(pattern string) ValidationRule
Click to show internal directories.
Click to hide internal directories.