1

I'm using an extension of baseValidationSchema for many of my schemas.

Now, inside a schema named contactSchema which contains many address related keys which I want to be using baseAddressSchema.

I tried to spread it as suggested in in this post:

export const contactSchema = baseValidationSchema.keys({
  ...baseAddressSchema,
  email: validateEmail(),
  firstName: validateName(),
  lastName: validateName(),
  phone: validatePhone(),
  spamFlag: validateBoolean()
});

But it throws an error:

Error: Schema can only contain plain objects

How should I do it right?

flow24
  • 793
  • 2
  • 5
  • 17

0 Answers0