validationrules

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2023 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLengthNotMultipleOfInvalid = validation.NewError("validation_length_not_multiple_of_invalid", "the length must be a multiple of {{.base}}")

ErrLengthNotMultipleOfInvalid is the error that returns in case of a length that is not multiple of a certain number.

Functions

This section is empty.

Types

type LengthMultipleOfRule

type LengthMultipleOfRule struct {
	// contains filtered or unexported fields
}

LengthMultipleOf is a validation rule that checks if a value's length is a multiple of the specified number.

func LengthMultipleOf

func LengthMultipleOf(base int) LengthMultipleOfRule

LengthMultipleOf returns a validation rule that checks if a value's length is a multiple of the specified number. This rule should only be used for validating strings, slices, maps, and arrays. An empty value is considered valid. Use the Required rule to make sure a value is not empty.

func (LengthMultipleOfRule) Error

Error sets the error message for the rule.

func (LengthMultipleOfRule) Validate

func (r LengthMultipleOfRule) Validate(value interface{}) error

Validate checks if the given value is valid or not.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL