function user_relationships_setting_validation in User Relationships 7
Same name and namespace in other branches
- 5 user_relationships_actions.inc \user_relationships_setting_validation()
- 5.2 user_relationships_actions.inc \user_relationships_setting_validation()
File
- ./
user_relationships.module, line 84 - User Relationships API. Module shell.
Code
function user_relationships_setting_validation($element, $validations) {
foreach ($validations as $validation => $info) {
$arguments = array(
$element['#value'],
);
if (isset($info['valid_options'])) {
$arguments[] = $info['valid_options'];
}
$valid = function_exists($validation) && call_user_func_array($validation, $arguments);
$valid = !$valid ? $validation == 'is_positive' && is_numeric($arguments) && (int) $arguments > 0 : FALSE;
$valid = !$valid ? $validation == 'is_non_negative' && is_numeric($arguments) && (int) $arguments > -1 : FALSE;
if (!$valid) {
form_set_error($element['#name'], $info['msg']);
}
}
}