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

Add documentation for sometimes rule, and fix nested sometimes bug #437

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

paulhbarker
Copy link

Prior to this change, if the sometimes rule was present on a nested property like so...

let rules = {
  'user.firstname': 'sometimes|required|string',
  ...
}

...the check to determine whether that nested property had data and needed to be validated was using Object.prototype.hasOwnProperty(), but "attributes" are delivered to the _suppliedWithData() method as "paths" in dot notation. This change fixes that by adding logic to determine if the "path" exists in the object, rather than passing a dot-notation string to Object.prototype.hasOwnProperty(), thus enabling the validation of nested properties with the sometimes rule.

A short sometimes rule addition was made to README.md as well 😄

…rties were not running any validation with the inclusion of the `sometimes` rule
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

Successfully merging this pull request may close these issues.

1 participant