You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import*asyupfrom"yup";constschema: yup.SchemaOf<Person>=yup.object({name: yup.string().required(),birthDate: yup.mixed<DateTime>().default(DateTime.utc()).required()// does not work});
I try use mixed, but it returns error
The types of 'fields.birthDate' are incompatible between these types.
Type 'MixedSchema<DateTime, AnyObject, DateTime>' is not assignable to type 'ObjectSchemaOf<DateTime, never> | Lazy<ObjectSchemaOf<DateTime, never>, any>'.
Type 'MixedSchema<DateTime, AnyObject, DateTime>' is missing the following properties from type 'ObjectSchema<{ get: ObjectSchemaOf<(unit: keyof DateTime) => number, never> | Lazy<ObjectSchemaOf<(unit: keyof DateTime) => number, never>, any>; ... 71 more ...; toRelativeCalendar: ObjectSchemaOf<...> | Lazy<...>; }, AnyObject, TypeOfShape<...>, AssertsShape<...>>': fields, _sortErrors, _nodes, _excludedEdges, and 11 more.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a type
Person
:I would like to validate birthDate using yup:
I try use mixed, but it returns error
How I can validate DateTime with yup?
Beta Was this translation helpful? Give feedback.
All reactions