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

feat: Pass propertyName to ValidateIf condition function #2415

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

maksimaderikha
Copy link

@maksimaderikha maksimaderikha commented Feb 17, 2024

Description

This PR passes the decorated property name to the condition function of ValidateIf decorator, so that it's possible to apply rules using the property name, e.g. build custom decorator to validate only if the property is presented in the object.

function IsOptional() {
  return ValidateIf((object, value, propertyName) =>
    object.hasOwnProperty(propertyName)
  );
}

P.S. No issue has been created since it's a really minor change.

Checklist

  • the pull request title describes what this PR does (not a vague title like Update index.md)
  • the pull request targets the default branch of the repository (develop)
  • the code follows the established code style of the repository
    • npm run prettier:check passes
    • npm run lint:check passes
  • tests are added for the changes I made (if any source code was modified)
  • documentation added or updated
  • I have run the project locally and verified that there are no errors

Fixes

fixes #[issue number], fixes #[issue number]

@maksimaderikha maksimaderikha force-pushed the feat/pass-property-name-to-validate-if-condition-fn branch from 6929a4a to c55ba88 Compare February 19, 2024 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant