validateRichText function

String? validateRichText(
  1. String? value
)

Validates if the input string is rich text, typically containing formatting such as HTML. This is a basic check and might need to be more sophisticated based on your rich text specifications.

Implementation

String? validateRichText(String? value) {
  if (value == null || value.isEmpty) {
    return 'Please enter rich text';
  }
  // Basic check for tags indicative of rich text
  if (!RegExp(r'<[a-z][\s\S]*>').hasMatch(value)) {
    return 'Enter valid rich text with formatting tags';
  }
  return null;
}