Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ type ValidationOption struct {
Nested []ValidationOption // Validation options for nested objects
}

// Validate checks the request body against the validation options and returns the first error.
// Validate validates the request body based on the provided validation options.
// It applies any transformers to update field values, enforces required fields,
// and executes associated validators, returning the first error encountered.
// For fields with nested validation options, it recursively validates the sub-objects.
func Validate(body map[string]interface{}, options []ValidationOption) error {
for _, option := range options {
value, exists := body[option.Key]
Expand Down