joomla/joomla-cms — pull request #4672 by itbra (2014-10-14 23:30:41+00:00)
Title: JFormValidator to pass element to handler

I found the form validator to process the passed value only making it hard to implement custom validation rules. I am using form field types that make use of additional data-attributes. These attributes may serve additional information required to implement a custom validation rule. For instance to validate a date field (filled by a datepicker) the validator not only needs the value, but also a rule (date format) to validate against. This rule may be geographically different and a data-attribute like `data-format="YY/MM/DD"`may allow to validate the selected date against this rule. When is is possible to pass the element being validated beside the value to be checked the handler may fetch the required date format from the data-format attribute and apply it. I did not touch the existing handlers' signature since they must not explicitely changed. The passed in element may be accessible via the implicitly accessable arguments object. But, if it is wished to add them a second function parameter for the element i can change it.

This PR implements a very tiny change providing more validation flexibility.