Skip to content

Validation error set via "error" prop in validateContent hook is silently ignored #482

Description

@florianmrz

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:

  1. Create a custom field plugin and use the validateContent hook, e.g.:
const plugin = useFieldPlugin({
  validateContent: content => {
    return { content, error: 'test' };
  },
});
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions