You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to implement custom validation for additionalFields but when i throw an Error on the lifecycle hook the Errors is not shown in strapi UI.
The user cannot save, but I'm not able to display an Error Message.
Background is that I want to validate my custom Fields, cause we need to option that Navigation Items can expire (Seasonal stuff like Easter, Super Bowl and so on)
Note: I tried various other Error Classes, but non was processed.
Code Example:
navigationCommonService.registerLifeCycleHook({
callback: async (event) => {
const { expiry_date, start_date } = event.params.data.additionalFields || {};
if (expiry_date && start_date) {
const expiryDate = new Date(expiry_date);
const startDate = new Date(start_date);
if (expiryDate <= startDate) {
throw new ApplicationError('Validation failed.');
}
}
},
contentTypeName: "navigation-item",
hookName: "beforeUpdate",
});
The text was updated successfully, but these errors were encountered:
Hello @cmaerz-dn , the validation is not exposed as part of the codebase yet. After discussions with some users of our plugin during the Strapi Conf we've decided to consider exposing the method for overwriting the zod schemas. Not yet on the backlog, but soon.
I tried to implement custom validation for
additionalFields
but when i throw an Error on the lifecycle hook the Errors is not shown in strapi UI.The user cannot save, but I'm not able to display an Error Message.
Background is that I want to validate my custom Fields, cause we need to option that Navigation Items can expire (Seasonal stuff like Easter, Super Bowl and so on)
Note: I tried various other Error Classes, but non was processed.
Code Example:
The text was updated successfully, but these errors were encountered: