[ParameterValidator] Ensure context has all user provided parameters (#1211)
* [ParameterValidator] Ensure context has all fields Previously if a bridge had a set of parameters like: const PARAMETERS = array( 'ContextA' => array( 'Param1' => array( 'name' => 'Param1', 'required' => true ) ), 'ContextB' => array( 'Param1' => array( 'name' => 'Param1', 'required' => true ), 'Param2' => array( 'name' => 'Param2', 'required' => true ) ) ) and a query specifying both Param1 and Param2 was provided a 'Mixed context parameters' error would be returned. This change ensures ContextA in the above example would not be considered a relevant context.
This commit is contained in:
parent
04be85996d
commit
4c78721f03
1 changed files with 7 additions and 0 deletions
|
@ -191,6 +191,13 @@ class ParameterValidator {
|
||||||
foreach($parameters as $context => $set) {
|
foreach($parameters as $context => $set) {
|
||||||
$queriedContexts[$context] = null;
|
$queriedContexts[$context] = null;
|
||||||
|
|
||||||
|
// Ensure all user data exist in the current context
|
||||||
|
$notInContext = array_diff_key($data, $set);
|
||||||
|
if(array_key_exists('global', $parameters))
|
||||||
|
$notInContext = array_diff_key($notInContext, $parameters['global']);
|
||||||
|
if(sizeof($notInContext) > 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
// Check if all parameters of the context are satisfied
|
// Check if all parameters of the context are satisfied
|
||||||
foreach($set as $id => $properties) {
|
foreach($set as $id => $properties) {
|
||||||
if(isset($data[$id]) && !empty($data[$id])) {
|
if(isset($data[$id]) && !empty($data[$id])) {
|
||||||
|
|
Loading…
Reference in a new issue