Describe the bug
It's possible to set an optional error message in the return type of the validateContent hook, but it's silently ignored / dropped. The error message is logged to the console, but nothing else happens.
The user is still allowed to save the content, even tho it was marked as invalid using the "error" property.
To Reproduce
Steps to reproduce the behavior:
- Create a custom field plugin and use the
validateContent hook, e.g.:
const plugin = useFieldPlugin({
validateContent: content => {
return { content, error: 'test' };
},
});
- Integrate the plugin into SB, open the console to see the following:
[Warning] The provided content is not valid, but it's still sent to the Visual Editor.
> test
Expected behavior
One would expect that this would
a) mark the field as invalid
b) render the error message in the SB UI to inform the user about the content entered being invalid
Desktop:
- OS: iOS
- Browser: Chrome v150.0.7871.115
- Version: @storyblok/field-plugin@1.7.1
Additional information
My current workaround is to mark the field as "required" in Storyblok and returning an empty string if the field should be considered invalid. This way I can mark the custom field as invalid, but cannot provide a proper validation error message to the user.
Describe the bug
It's possible to set an optional error message in the return type of the
validateContenthook, but it's silently ignored / dropped. The error message is logged to the console, but nothing else happens.The user is still allowed to save the content, even tho it was marked as invalid using the "error" property.
To Reproduce
Steps to reproduce the behavior:
validateContenthook, e.g.:Expected behavior
One would expect that this would
a) mark the field as invalid
b) render the error message in the SB UI to inform the user about the content entered being invalid
Desktop:
Additional information
My current workaround is to mark the field as "required" in Storyblok and returning an empty string if the field should be considered invalid. This way I can mark the custom field as invalid, but cannot provide a proper validation error message to the user.