Files
lo/docs/data/core-validate.md
T
2025-10-06 19:59:26 +02:00

761 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
Validate validate errors.go#L13 core error-handling https://go.dev/play/p/vPyh51XpCBt
core#error-handling#validate
core#error-handling#mustx
core#error-handling#tryx
core#error-handling#tryorx
core#error-handling#assert
0
func Validate(ok bool, format string, args ...any) error

Creates an error when a condition is not met; returns nil when it is.

slice := []string{"a"}

err := lo.Validate(len(slice) == 0, "Slice should be empty")
// error("Slice should be empty")

err := lo.Validate(len(slice) == 0, "Slice should be empty but contains %v", slice)
// error("Slice should be empty but contains [a]")