Closed chertik77 closed 3 months ago
By object merging:
const Schema = v.object({
...OtherSchema.entries,
avatar: v.optional(v.instance(File)),
});
avatar: v.optional(v.instance(File)),
Thanks you so much 😀
Also, I merge title to card schema
export const TitleSchema = v.object({
title: v.string([
v.toTrimmed(),
v.minLength(3, 'Please enter at least 3 characters.')
])
})
export const CardSchema = v.object({
...TitleSchema.entries,
description: v.string([
v.toTrimmed(),
v.minLength(3, 'Please enter at least 3 characters.')
]),
priority: v.picklist(priorities),
deadline: v.date()
})
but description
has same properties as title, how i can merge title properties into desc field but keep description
as a title.
And here i"m getting object instead of actual string
type HelpSchema = {
email: {
email: string;
};
comment: string;
}
export const HelpSchema = v.object({
email: v.pick(SigninSchema, ['email']),
comment: v.string([
v.toTrimmed(),
v.minLength(5, 'Please enter at least 5 characters.')
])
})
If you have just started using Valibot, I recommend using the release candidate we just released: https://valibot.dev/guides/migrate-from-v0.30.0/
but
description
has same properties as title, how i can merge title properties into desc field but keepdescription
as a title.
const StringSchema = v.string([
v.toTrimmed(),
v.minLength(3, 'Please enter at least 3 characters.')
]);
export const TitleSchema = v.object({
title: StringSchema,
});
export const CardSchema = v.object({
...TitleSchema.entries,
description: StringSchema,
priority: v.picklist(priorities),
deadline: v.date()
});
And here i"m getting object instead of actual string
pick
is similar to Pick
in TypeScript. It's the wrong procedure for what you are aiming for.
export const HelpSchema = v.object({
email: SigninSchema.entries.email, // <--
comment: v.string([
v.toTrimmed(),
v.minLength(5, 'Please enter at least 5 characters.')
])
})
Thanks, u're a lifesaver, i'm new here, but i like it
Hey how i can add new field
avatar
toPartialSignupSchema
but not like an object...