A few notes from my personal gripes about what InputFilter
is and does.
InputFilter
is a terrible name as the class mixes sanitation and validation. Rename to something far more appropriate (e.g.InputManager
?).- Data should only be processed, not stored - remove
setData()
For example, if both raw and sanitized data are required:
$sanitizedData = $this->inputManager->sanitize($data->toArray());
$validationResult = $this->inputManager->validate($sanitizedData);
if ($validationResult->isValid()) {
// hooray!
} else {
$messages = $validationResult->getMessages();
}
Also, if all we need is the result:
$validationResult = $this->inputManager->sanitizeAndValidate($data->toArray());
if ($validationResult->isValid()) {
// hooray!
} else {
$messages = $validationResult->getMessages();
}
Do you understand the concept of Separation of Concerns? That's the key objective here. Bridge components would be better organized outside of the core library. A Zfc version would be no different than the current version in terms of requirements. It's not complex: If you need a pre-built input module, just use the Zfc version; if you need more flexibility, use the individual components as necessary and roll your own. But, if you need flexibility, you should NOT be forced to load "20 modules" (a gross exaggeration) just for one component.
would become