Yup: Remove extra fields in .cast() ?

Created on 23 Jul 2019  路  2Comments  路  Source: jquense/yup

I'd like to strip/remove fields not defined in the schema - is this possible w/ yup at all?

Most helpful comment

const contactSchema = yup.object({
name: yup.string()
.required(),
})

const v = contactSchema.noUnknown().cast({
name: 'cory',
age: 33
})

All 2 comments

schema.cast(value, { stripUnknown: true})

const contactSchema = yup.object({
name: yup.string()
.required(),
})

const v = contactSchema.noUnknown().cast({
name: 'cory',
age: 33
})

Was this page helpful?
0 / 5 - 0 ratings