mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-24 00:53:10 +02:00
[ParameterValidator] Refactor 'validation' into 'ParameterValidator'
Adds a new class 'ParameterValidator' to replace the functions from 'validator.php', separating private functions from 'validateData' to class private functions in the process. Instead of echoing error messages, adds messages to a private variable, accessible via 'getInvalidParameters'. BridgeAbstract now adds invalid parameter names to the error message.
This commit is contained in:
@@ -195,8 +195,18 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!validateData($inputs, static::PARAMETERS)) {
|
||||
returnClientError('Invalid parameters value(s)');
|
||||
$validator = new ParameterValidator();
|
||||
|
||||
if(!$validator->validateData($inputs, static::PARAMETERS)) {
|
||||
$parameters = array_map(
|
||||
function($i){ return $i['name']; }, // Just display parameter names
|
||||
$validator->getInvalidParameters()
|
||||
);
|
||||
|
||||
returnClientError(
|
||||
'Invalid parameters value(s): '
|
||||
. implode(', ', $parameters)
|
||||
);
|
||||
}
|
||||
|
||||
// Guess the paramter context from input data
|
||||
|
Reference in New Issue
Block a user