There are many schemes and they are combined by some identical fields. When changing the fields of one scheme, you need to change the same fields, but in other schemes. And I wanted the fields of different schemes, or the schemes themselves, to refer to or inherit one common scheme. Something like:
import * as Yup from "yup";
import {commonSchema} from "./common";
export const parentSchema = Yup.object().shape({
FirstName: Yup.string()
.min(2, `Имя не может состоять менее чем из 2 сомволов`)
.max(50, `Имя не может состоять более чем из 50 сомволов`)
.required(`Поле 'Имя' обязательное для заполнения`),
SecondName: ref(commonSchema.SecondName)
});
// commonSchema
export const commonSchema = Yup.object().shape({
SecondName: Yup.string()
.min(2, `Отчество не может состоять менее чем из 2 сомволов`)
.max(100, `Отчество не может состоять более чем из 100 сомволов`)
});
In short, making changes to one general schema will not have to make changes to other schemas with the same fields.
I would like to collect all the common properties in one file. And then refer to the necessary properties from each file