I'm solving this problem. I'm using yup for formik validation. Code for scheme:
const schema = yup.object().shape<Partial<NoteInterface>>({
noteName: yup.string().required().max(32),
groupId: yup.number().required(),
noteText: yup.string().required().max(32),
noteDuration: yup.string().required().max(32),
noteTags: yup.array().of(yup.string()),
});
And model code overhere:
export enum cNote {
noteId = 'noteId',
groupId = 'groupId',
noteName = 'noteName',
noteText = 'noteText',
noteDuration = 'noteDuration',
noteCreation = 'noteCreation',
noteTags = 'noteTags',
}
export interface NoteInterface {
noteId: string;
groupId: number;
noteName: string;
noteText: string;
noteDuration: string;
noteCreation: string;
noteTags: string[];
}
export const Note = (): NoteInterface => ({
noteId: '',
groupId: 0,
noteName: '',
noteText: '',
noteDuration: '',
noteCreation: '',
noteTags: [],
});
Everything works fine, except for noteTags which is having this problem:
TS2322: Type 'NotRequiredArraySchema<string | undefined>' is not assignable to type 'Ref | Schema<string[] | undefined> | MixedSchema<string[] | undefined> | undefined'. Type 'NotRequiredArraySchema<string | undefined>' is not assignable to type 'MixedSchema<string[] | undefined>'.
thank you for your time