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 ability to specify validation rules as functions #377

Open
rglover opened this issue Apr 25, 2024 · 0 comments
Open

Add ability to specify validation rules as functions #377

rglover opened this issue Apr 25, 2024 · 0 comments
Assignees
Labels
feature Something new to add @joystick.js/node Related to the @joystick.js/node package.
Projects

Comments

@rglover
Copy link
Contributor

rglover commented Apr 25, 2024

The function should receive the entirety of the input from the client, returning a validation rule. The idea being to make it so that a developer can conditionally apply rules based on other input. For example, if the payment provider is stripe, make the source field required: true, otherwise, required: false.

input: {
  provider: {
    type: 'string',
    allowed_values: ['paypal', 'stripe'],
    required: true,
  },
  source: (input = {}) => ({
    type: 'string',
    required: input?.provider === 'stripe'
  }),
}
@rglover rglover added feature Something new to add @joystick.js/node Related to the @joystick.js/node package. labels Apr 25, 2024
@rglover rglover self-assigned this Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Something new to add @joystick.js/node Related to the @joystick.js/node package.
Projects
1.0.0
Awaiting triage
Development

No branches or pull requests

1 participant