joystick icon indicating copy to clipboard operation
joystick copied to clipboard

Add ability to specify validation rules as functions

Open rglover opened this issue 1 year ago • 0 comments

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 avatar Apr 25 '24 07:04 rglover