Validator for ExtJS Checkbox

Very unfortunately ExtJS doesn’t offer a validator for its checkbox component.
Normally a validator checks whether a field is valid and takes care of displaying an error message if not. For a checkbox we would like that to happen if the checkbox is not selected.
Overriding the validate function of the checkbox we can provide such a functionality for all checkbox instances we are about to create:

The validator can be customized using the properties validateField and validateMessage.

Here’s a small code example: