Our validation is an extension of the jQuery Validation plugin. We don't have any specific documentation for this since it's just using that plugin. It's primarily interfaced with the cbValidator class. You can use cbValidator::addRule to inject a new validation rule without needing to really know how to use jQuery Validation as it'll string most of the JS up for you.
How you interface with that API is up to you, but given you're basically adding a new fieldtype I'd recommend making a custom fieldtype plugin. There's several examples of how to do that throughout our plugins, but I'd start with CB Query Field and CB Code Field since that's all those two plugins do.
If you just want to inject the validation rule you could probably do a Code action in CB Auto Actions on onBeforegetFieldRow trigger. Below is how to use cbValidator to add a rule.
Structure
Code:
cbValidator::addRule( 'RULE_NAME_HERE', 'JAVASCRIPT_HERE', 'INVALID_MESSAGE_HERE' );
Example
Code:
cbValidator::addRule( 'isapple', 'return ( value === 'apple' );', 'Not an apple!' );
The JAVASCRIPT_HERE only has 2 properties. "value" which is whatever the value is the user input or selected and "element" which is just the input itself. New validation rules can be added entirely from jQuery as well if you want. Below is an example of that.
Code:
$.validator.addMethod( 'maxWords', function( value, element, params ) {
return this.optional( element ) || ( $( value ).text().match( /\b\w+\b/g ).length <= params );
}, $.validator.format( 'Please enter {0} words or less.' ) );
Neither of these add the rule to anything yet. You either need to add "data-rule-RULE_NAME_HERE" attribute to your input when outputting it or dynamically with JS.
All of this will basically be gone in CB 3.0 though as we'll be just using native form validation behavior or Joomla's form validation. So might want to leave a TODO note that eventually it'll need to be redone a little bit.