Repository navigation
Add conditional required validators - #366
Open
chaungoclong wants to merge 1 commit into
Open
chaungoclong wants to merge 1 commit into
chaungoclong wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces 5 new validation rules, expanding support for conditional validation and resolving #235.
New Validators
required_with: Requires the field when any of the specified fields are present and non-empty.required_with_all: Requires the field when all of the specified fields are present and non-empty.required_without: Requires the field when any of the specified fields are missing or empty.required_without_all: Requires the field when all of the specified fields are missing or empty.required_array_keys: Requires the field to be an array containing all specified keys.Changes
Usage Examples
1.
required_withRequire an email address when either
first_nameorlast_nameis provided.String format:
Array format:
2.
required_with_allRequire
shipping_addresswhen bothfirst_nameandlast_nameare provided.String format:
Array format:
3.
required_withoutRequire at least one of two contact methods,
phoneormobile.String format:
Array format:
4.
required_without_allRequire an email address when both
phoneandmobileare missing or empty.String format:
Array format:
5.
required_array_keysRequire
datato be an array containing bothidandname.String format:
Array format:
Issue
Resolves #235.