yuptypes

export const yuptypes = (schema) => {
const propTypes = {};
for (const key in schema.fields) {
propTypes[key] = function checkYupSchema(
props,
propName,
componentName,
location,
propFullName,
secret
) {
try {
schema.validateSyncAt(key, props, { strict: true });
return null;
} catch (err) {
return new Error(
`Invalid ${location} `${propName}` supplied to ${componentName};${err.message.replace(
key,
""
)}`
);
}
};
}
return propTypes;
};
yuptypes.js