fix: use zod issues instead of errors for build compatibility
This commit is contained in:
parent
dda9ae0f4a
commit
ea551469b7
@ -111,7 +111,7 @@ export async function POST(request: NextRequest) {
|
|||||||
const parseResult = PostSchema.safeParse(body);
|
const parseResult = PostSchema.safeParse(body);
|
||||||
if (!parseResult.success) {
|
if (!parseResult.success) {
|
||||||
const errors: Record<string, string[]> = {};
|
const errors: Record<string, string[]> = {};
|
||||||
parseResult.error.errors.forEach((err) => {
|
parseResult.error.issues.forEach((err) => {
|
||||||
const key = String(err.path[0]);
|
const key = String(err.path[0]);
|
||||||
if (!errors[key]) errors[key] = [];
|
if (!errors[key]) errors[key] = [];
|
||||||
errors[key].push(err.message);
|
errors[key].push(err.message);
|
||||||
@ -166,7 +166,7 @@ export async function PUT(request: NextRequest) {
|
|||||||
const parseResult = PostPatchSchema.safeParse(body);
|
const parseResult = PostPatchSchema.safeParse(body);
|
||||||
if (!parseResult.success) {
|
if (!parseResult.success) {
|
||||||
const errors: Record<string, string[]> = {};
|
const errors: Record<string, string[]> = {};
|
||||||
parseResult.error.errors.forEach((err) => {
|
parseResult.error.issues.forEach((err) => {
|
||||||
const key = String(err.path[0]);
|
const key = String(err.path[0]);
|
||||||
if (!errors[key]) errors[key] = [];
|
if (!errors[key]) errors[key] = [];
|
||||||
errors[key].push(err.message);
|
errors[key].push(err.message);
|
||||||
|
|||||||
@ -121,7 +121,7 @@ export const PublicationLayout: React.FC<PublicationLayoutProps> = ({
|
|||||||
const parseResult = PostSchema.safeParse(Object.fromEntries(formData.entries()));
|
const parseResult = PostSchema.safeParse(Object.fromEntries(formData.entries()));
|
||||||
if (!parseResult.success) {
|
if (!parseResult.success) {
|
||||||
const errors: Record<string, string> = {};
|
const errors: Record<string, string> = {};
|
||||||
parseResult.error.errors.forEach((err) => {
|
parseResult.error.issues.forEach((err) => {
|
||||||
const field = err.path[0] as string;
|
const field = err.path[0] as string;
|
||||||
errors[field] = err.message;
|
errors[field] = err.message;
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user