[eluser]OverZealous[/eluser]
Not a bug. If you don't include 'required', and the field is empty, DataMapper doesn't process any rules — since many of the rules might fail on an empty field (like exact_length).
However, if you do include 'required', when saving an object it might throw an error if that field is empty.
This is mitigated on one rule only: 'matches'. DataMapper has a special provision to pre-fill in the other field if a field has the 'matches' rule.
One way to avoid it (I have used) is to create a custom _required function just for the model that needs it. This method (if only used on one field) can simply return TRUE, or it can return TRUE by checking the passed in field:
Code:
// in User, for example
function _required($field, $param) {
if($field == 'custom_username') {
return TRUE;
} else {
return parent::_required($field, $param);
}
}