Title: RichText Component: Block validation error
Last modified: August 13, 2024

---

# RichText Component: Block validation error

 *  [aboutsam](https://wordpress.org/support/users/aboutsam/)
 * (@aboutsam)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/richtext-component-block-validation-error/)
 * Hey guys, in one of my custom blocks i use the RichText component.
 * I followed the guidelines here in these article: [https://developer.wordpress.org/block-editor/reference-guides/richtext/#example](https://developer.wordpress.org/block-editor/reference-guides/richtext/#example)
 * Unfortunately, i receive in my console.log an Block validation error.
 *     ```wp-block-code
       Content generated by save function:<h2 class="wp-block-studio-wai-heading studio-wai-heading has-object-object-font-size">Block 1 INNOVATIVE BRAND STRATEGY &amp; SUCCESS</h2>Content retrieved from post body:<h2 class="wp-block-studio-wai-heading studio-wai-heading">Block 1 INNOVATIVE BRAND STRATEGY &amp; SUCCESS</h2>
       ```
   
 * The only difference i mentioned is the classname “has-object-object-font-size”
   which is added by save.js (see code above).
 * **save.js:**
 *     ```wp-block-code
       const save = function ({ attributes }) {	const { content, heading } = attributes;	const blockProps = useBlockProps.save({		className: classnames('studio-wai-heading'),	});	return <RichText.Content {...blockProps} tagName={heading} value={content} />;};
       ```
   
 * **edit.js:**
 *     ```wp-block-code
       return (	<RichText		{...blockProps}		tagName={heading}		value={attributes.content}		allowedFormats={['core/bold', 'core/italic']}		onChange={(content) => setAttributes({ content })}		placeholder={__('Heading...')}	/>);
       ```
   
 * **attributes.js**
 *     ```wp-block-code
       content: {		type: 'string',		source: 'html',		selector: 'h1,h2,h3,h4,h5,h6',	},
       ```
   
 * How i can solve the Block validation error?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/richtext-component-block-validation-error/#post-17951098)
 * I had a problem like this some time ago. The reason is that the output of the
   block differs from the expected format when loading. As you have already seen,
   the difference is the class.
 * But I don’t see that this is added in save.js in your case? I also don’t recognize
   the class. Through a search I found this topic here: [https://wordpress.org/support/topic/editors-kit-adding-incorrect-classes-to-blocks/](https://wordpress.org/support/topic/editors-kit-adding-incorrect-classes-to-blocks/)–
   have you activated the plugin mentioned? If so, deactivate all plugins except
   the one you are currently developing with.
 *  Thread Starter [aboutsam](https://wordpress.org/support/users/aboutsam/)
 * (@aboutsam)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/richtext-component-block-validation-error/#post-17959253)
 * That’s right! I do not add the class in save.js. I have a value in attributes
   which was called “fontSize”
 *     ```wp-block-code
       fontSize: {	type: Object,	...},
       ```
   
 * I’m not 100% sure if this is the right solution but when i rename **fontSize**
   to e.g. **testFontSize** the problem no longer occurs. I think because fontSize
   is already use by global block settings.
 * My Solution: rename fontSize to myCustomFontsize

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘RichText Component: Block validation error’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [aboutsam](https://wordpress.org/support/users/aboutsam/)
 * Last activity: [1 year, 9 months ago](https://wordpress.org/support/topic/richtext-component-block-validation-error/#post-17959253)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
