Open juliushuck opened 1 year ago
I would like to have this feature, however, finding consistency cross all different lib is challenging, would be good for each lib has a way to serialize the schema to a JSON format so hook form can easily consume, but the only visible option right now is probably what you suggested and JSON schema.
const formController = useFormController({
resolver: joiResolver(
eventValidationSchemas.creation.forms.settings.real, // why not just export this?
validationOptions
),
defaultValues: defaultFormData,
});
In my date picker component I want to access the validation schema of the form to extract the min and max values for the date directly from the validation schema to have a single source of truth. For that it would be nice to have sth like this:
My way to extract the specific validation rule for joi would be
For that to work, the joiResolver function would have to return an object or so to the form controller, which can then expose the schma and use the resolver function to validate the data.
I could also wrap the formController for my purpose, but I think it would be nice to include this functionality by default.