You can use the .htninja script.
For instance, this assumes that you don’t want anyone to post a comment shorter than 15 characters using the WordPress built-in comment forms (it won’t work if you’re using third-party plugins to create forms):
<?php
/*
+===========================================================================================+
| NinjaFirewall optional configuration file |
| |
| See: https://blog.nintechnet.com/ninjafirewall-wp-edition-the-htninja-configuration-file/ |
+===========================================================================================+
*/
// Block comments that are shorter than 15 characters
if ( strpos( $_SERVER['SCRIPT_FILENAME'], 'wp-comments-post.php') !== FALSE &&
strlen( $_POST['comment'] ) < 15 ) {
return 'BLOCK';
}