joystick
joystick copied to clipboard
Add ability to specify validation rules as functions
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'
}),
}