coen-hyde/Shanty-Mongo — pull request #98 by hecticjeff (2012-10-05 20:23:12+00:00)
Title: Custom requirements

I wanted to run a custom `Zend_Filter_Interface` class against a field, but looking at the source code it seems that Shanty is special cased to look for `Zend_Filter_` as a prefix.

I know you can register a custom validator with Shanty using `storeRequirement`…

```php
Shanty_Mongo::storeRequirement('PigLatin', new My_Filter_PigLatin())
```

…but as @tholder mentioned in #36, this makes it harder to track which code is using which filter/validator a given model is using.

This change first checks if a filter or validator is an existing class, then it adds the prefix if the class isn't found. Allowing models to declare filters and validators that are class names.

```php
class User extends Shanty_Mongo_Document
{
protected static $_requirements = array(
'bio' => array('Filter:My_Filter_PigLatin')
);
}
```