Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scheduling): update error message #20208

Draft
wants to merge 1 commit into
base: v5/main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -107,7 +107,7 @@ describe('Release controller', () => {
};

// @ts-expect-error partial context
expect(() => releaseController.create(ctx)).rejects.toThrow('name is a required field');
expect(() => releaseController.create(ctx)).rejects.toThrow('This field is required');
});
});

Expand All @@ -129,7 +129,7 @@ describe('Release controller', () => {
};

// @ts-expect-error partial context
expect(() => releaseController.update(ctx)).rejects.toThrow('name is a required field');
expect(() => releaseController.update(ctx)).rejects.toThrow('This field is required');
});

it('throws an error given unknown request arguments', () => {
Expand Down
27 changes: 23 additions & 4 deletions packages/core/content-releases/shared/validation-schemas.ts
@@ -1,24 +1,43 @@
import * as yup from 'yup';
import { translatedErrors } from '@strapi/admin/strapi-admin';

export const RELEASE_SCHEMA = yup
.object()
.shape({
name: yup.string().trim().required(),
name: yup.string().trim().required({
id: translatedErrors.required.id,
defaultMessage: 'This field is required',
}),
scheduledAt: yup.string().nullable(),
isScheduled: yup.boolean().optional(),
time: yup.string().when('isScheduled', {
is: true,
then: yup.string().trim().required(),
then: yup.string().trim().required({
id: translatedErrors.required.id,
defaultMessage: 'This field is required',
}),
otherwise: yup.string().nullable(),
}),
timezone: yup.string().when('isScheduled', {
is: true,
then: yup.string().required().nullable(),
then: yup
.string()
.required({
id: translatedErrors.required.id,
defaultMessage: 'This field is required',
})
.nullable(),
otherwise: yup.string().nullable(),
}),
date: yup.string().when('isScheduled', {
is: true,
then: yup.string().required().nullable(),
then: yup
.string()
.required({
id: translatedErrors.required.id,
defaultMessage: 'This field is required',
})
.nullable(),
otherwise: yup.string().nullable(),
}),
})
Expand Down