Issue with optional strings in schema validation
I've got this schema. I'm getting a frustrating error on my optional strings: "expected undefined but got """ (or any other string value). Any tips?
const Email = S.string.pipe(
S.pattern(/^(?!\.)(?!.*\.\.)([A-Z0-9_+-.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9-]*\.)+[A-Z]{2,}$/i),
);
// -- Types and validation.
const FeedbackFormSchema = S.struct({
name: S.optional(S.string.pipe(S.nonEmpty(), S.maxLength(120))),
email: S.optional(Email.pipe(S.nonEmpty(), S.maxLength(256))),
message: S.optional(S.string.pipe(S.nonEmpty(), S.maxLength(10000))),
});