PHP
Some modules allow users to define extra validation rules defined in a hook. (e.g hook_webform_validation_validators()). To support these custom rules, clientside validation has its own hook, hook_clientside_validation_rule_alter. We had to use an 'alter' hook because module_invoke and module_invoke_all does not support passing arguments by reference, drupal_alter does.
If you want to add support for your custom validation rules defined for webform_validation, fapi_validation or field_validation, you can use this hook. Every validation rule that is defined for any of these modules and is not implemented as standard by clientside_validation is passed through to this hook (given that the related clientside validation module is enabled and that clientside validation is enabled for the specific form).
The first parameter to this hook is an array. This array, consitently named $js_rules, is passed by reference throughout the entire module and is the key to the entire functionality of this module.
The second parameter is the form element or webform component (dependend on third parameter)
The third parameter, named $context, is a structured array. It consists of the following keys:
- 'type': The type of form validation we are dealing with. Can be either 'webform', 'fapi', 'field_validation' or 'element_validate'.