migrate to zod v4
This commit is contained in:
@@ -71,7 +71,7 @@ export const ClientUpdateSchema = schemaForType<UpdateClientType>()(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// TODO: investigate if coerce is bad
|
// TODO: investigate if coerce is bad
|
||||||
const clientId = z.number({ message: t('zod.client.id'), coerce: true });
|
const clientId = z.coerce.number({ message: t('zod.client.id') });
|
||||||
|
|
||||||
export const ClientGetSchema = z.object({
|
export const ClientGetSchema = z.object({
|
||||||
clientId: clientId,
|
clientId: clientId,
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export function validateZod<T>(
|
|||||||
if (v.message.startsWith('zod.')) {
|
if (v.message.startsWith('zod.')) {
|
||||||
switch (v.code) {
|
switch (v.code) {
|
||||||
case 'too_small':
|
case 'too_small':
|
||||||
switch (v.type) {
|
switch (v.origin) {
|
||||||
case 'string':
|
case 'string':
|
||||||
newMessage = t('zod.generic.stringMin', [
|
newMessage = t('zod.generic.stringMin', [
|
||||||
t(v.message),
|
t(v.message),
|
||||||
@@ -100,7 +100,7 @@ export function validateZod<T>(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'invalid_type': {
|
case 'invalid_type': {
|
||||||
if (v.received === 'null' || v.received === 'undefined') {
|
if (v.input === null || v.input === undefined) {
|
||||||
newMessage = t('zod.generic.required', [
|
newMessage = t('zod.generic.required', [
|
||||||
v.path.join('.'),
|
v.path.join('.'),
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user