implements accessibility measures and finishes Link richText element
This commit is contained in:
3
src/fields/richText/defaultValue.js
Normal file
3
src/fields/richText/defaultValue.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export default [{
|
||||
children: [{ text: '' }],
|
||||
}];
|
||||
@@ -1,3 +1,5 @@
|
||||
const defaultRichTextValue = require('./richText/defaultValue');
|
||||
|
||||
const defaultMessage = 'This field is required.';
|
||||
|
||||
const optionsToValidatorMap = {
|
||||
@@ -92,15 +94,9 @@ const optionsToValidatorMap = {
|
||||
return true;
|
||||
},
|
||||
richText: (value, options) => {
|
||||
//! Need better way to share an empty text node
|
||||
//! it is used here and in field-types/RichText
|
||||
const emptyRichTextNode = [{
|
||||
children: [{ text: '' }],
|
||||
}];
|
||||
|
||||
if (options.required) {
|
||||
const blankSlateJSNode = JSON.stringify(emptyRichTextNode);
|
||||
if (value && JSON.stringify(value) !== blankSlateJSNode) return true;
|
||||
const stringifiedDefaultValue = JSON.stringify(defaultRichTextValue);
|
||||
if (value && JSON.stringify(value) !== stringifiedDefaultValue) return true;
|
||||
return 'This field is required.';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user