mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-12 15:04:38 +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:
parent
e3a5a6a170
commit
f853ffc07c
4 changed files with 136 additions and 98 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue