HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Minimum Characters
Gary_Leeds
New
Hi everyone,
I know there is a way to limit the maximum number of characters in posts, but is there a way to set a minimum?
Tagged:
0
Answers
Welcome to the community!
This is a really interesting question. There are no current validation rules for minimum length.
What you need is a plugin that a) defines a function called ValidateMinimumLength and b) hooks into the comment/discussion model to validate the body field against this new MinimumLength rule.
Alternatively to a), you could just check the length yourself without applying a new rule and just add an error yourself. This would probably be more approachable for a new plugin developer.
Don't know where to start? Check out the Hello World plugin article over on the wiki: http://vanillawiki.homebrewforums.net/index.php/Hello_World_Plugin
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Possibly out of my expertise.
Just start with it! I think such a plugin would be nice and as hgtonight already said, it could be a good beginners work
Look at the link of the hello world plugin, look at some simple plugins to see how you can hook into Vanillas events and then look at Vanillas source code:
https://github.com/vanilla/vanilla/blob/2.1/applications/vanilla/models/class.discussionmodel.php#L1376
https://github.com/vanilla/vanilla/blob/2.1/applications/vanilla/models/class.commentmodel.php#L782
and maybe also for activity posts: https://github.com/vanilla/vanilla/blob/2.1/applications/dashboard/models/class.activitymodel.php#L896
If you get stuck, just come back with your questions!