Aspen-Discovery/aspen-discovery

DataObjectUtil::validateObject does not recursively traverse $structure

Closed this issue · 2 comments

If a form structure is defined has more than one level, i.e. it contains fields within a section, any fields within a section will not receive server validation, even if they have a valid serverValidation functiondefined.

I have a few sections within the SSO form definition, for example:

'ssoPatronTypeSection' => array('property' => 'ssoPatronTypeSection', 'type' => 'section', 'label' => 'Patron type', 'hideInLists' => true, 'permissions' => ['Library ILS Options'], 'properties' => array(
    'ssoPatronTypeAttr' => array('property'=>'ssoPatronTypeAttr', 'serverValidation' => 'validatePatronType', 'type'=>'text', 'label'=>'Name of the identity provider attribute that contains the user\'s patron type', 'description'=>'The user\'s patron type, this should be a value that is recognised by Aspen. If this is not supplied, please provide a fallback value below', 'size'=>'512', 'hideInLists' => false, 'permissions' => ['Library ILS Connection']),
    'ssoPatronTypeFallback' => array('property'=>'ssoPatronTypeFallback', 'type'=>'text', 'label'=>'A fallback value for patron type', 'description'=>'A value to be used in the event the identity provider does not supply a patron type attribute, this should be a value that is recognised by Aspen.', 'size'=>'512', 'hideInLists' => false, 'permissions' => ['Library ILS Connection']),
)),

ssoPatronTypeAttr has a serverValidation function defined, the function has been created, but is never executed.

The reason appears to be that DataObjectUtil::validateObject only iterates properties that appear at the top level of $structure, it should probably recursively traverse the tree, gathering validation results as it goes.

I'll create a PR implementing this fix.

Looks like this issue can be closed since #632 was merged?