Documentation
¶
Overview ¶
Example (RangeInt) ¶
package main import ( "context" "go.llib.dev/frameless/pkg/validate" ) func main() { type T struct { V int `range:"0..100"` } ctx := context.Background() validate.Value(ctx, T{V: 42}) // no error validate.Value(ctx, T{V: -1}) // validate.Error validate.Value(ctx, T{V: 101}) // validate.Error }
Example (RangeIntMulti) ¶
package main import ( "context" "go.llib.dev/frameless/pkg/validate" ) func main() { type T struct { Num1 int `range:"0..100"` Num2 int `range:"0..25,30..50"` } ctx := context.Background() _ = validate.Value(ctx, T{}) }
Index ¶
- Constants
- func SkipValidate(ctx context.Context) context.Contextdeprecated
- func Struct(ctx context.Context, v any) error
- func StructField(ctx context.Context, field reflect.StructField, value reflect.Value) error
- func Value[T any](ctx context.Context, v T) error
- type Error
- type Option
- type Validatable
- type ValidationErrordeprecated
- type Validatordeprecated
- type X
Examples ¶
Constants ¶
View Source
const ImplementationError errorkit.Error = "ImplementationError"
Variables ¶
This section is empty.
Functions ¶
func SkipValidate
deprecated
added in
v0.301.0
SkipValidate option indicates that the function is being used inside a Validate(context.Context) error method.
When this option is set, the Validate function call is skipped to prevent an infinite loop caused by a circular Validate call.
Deprecated: no longer needed to use if you migrated to the new Validatable interface signature.
func StructField ¶
Types ¶
type Error ¶ added in v0.288.0
type Error struct{ Cause error }
Error is a validation error, that represents an incorrect content.
type Validatable ¶ added in v0.301.0
Validatable is a value that can self-validate.
type ValidationError
deprecated
type ValidationError = Error
Deprecated: use validate.Error instead
Click to show internal directories.
Click to hide internal directories.