Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bail on first error #89

Open
jcobhams-cp opened this issue Feb 13, 2020 · 0 comments
Open

Bail on first error #89

jcobhams-cp opened this issue Feb 13, 2020 · 0 comments

Comments

@jcobhams-cp
Copy link

jcobhams-cp commented Feb 13, 2020

Would it be possible to return the error bag on the first failure as opposed to running all the rules.

  1. Bail when the first rule in a ruleset for a field fails
    example:
rules := govalidator.MapData{
		"email": []string{"required"},
		"password": []string{"required"},
		"some_field": []string{"bail", "required", "in:something,somethingelse"},
	}
  1. Bail when the first rule for the entire validation fails.
opts := govalidator.Options{
		Request:         r        // request object
		Rules:           rules,    // rules map
		Messages:        messages, // custom message map (Optional)
		RequiredDefault: true,     // all the field to be pass the rules
                 BailFirstError: true //returns the error bag with only one item
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant