The entity schema containing all the attributes of the entity.
An object for custom translations
Optional
omittedFields: string[]The list of attributes/relations to ignore.
The yup object schema containing various primitive types to validate.
Here is an example usage with react-hook-form
:
import {useForm} from "react-hook-form";
import {yupResolver} from "@hookform/resolvers/yup";
import {getValidationSchemaFromYams} from "@cubicweb/yup";
const entityTypeParser = getValidationSchemaFromYams(
entityTypeSchema,
errorsTranslations,
omittedFields
);
const {...} = useForm({
resolver: yupResolver(entityTypeParser),
});
Generated using TypeDoc
If you use useCubicWebForm, then there is no need to manually use this function.
But if you want to write your own hooks, you might still need the yup validation. In that case, you can use this function to generate a Yup object, which you can then use in the the rest of your app.