Closed albertcito closed 2 years ago
I believe there is a shape property on the builder where you can get the Yup shape object with props if that is what you mean
I figure out I can do it as well:
const schema = Yup.object().shape({ name: Yup.string().required() });
const { name } = schema.fields
You can do sth like this using shapeConfig
const { buildYup } = require("json-schema-to-yup");
const name = {
description: "Name of the person",
type: "string",
required: true,
trim: true,
...
}
const json = {
properties: {
name
}
}
const { shapeConfig } = buildYup(json, config);
const schema = yup.object().shape({
...shapeConfig,
...customShapeConfig,
});
const { name } = schema.fields
I'm working with a library for my forms. So I have to register the input in this way
const name = register('name', Yup.string().trim().required());
Is there a way to build the properties only? In this way for instance: