Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions core/components/formit/src/FormIt/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,10 @@ public function validate($key, $value, $type = '')

/** @var array $invNames An array of invalid hook names to skip */
$invNames = array('validate','validateFields','addError','__construct');
$customValidators = !empty($this->config['customValidators']) ? $this->config['customValidators'] : '';
$customValidators = explode(',',$customValidators);
$customValidators = !empty($this->config['customValidators']) ? $this->config['customValidators'] : array();
if (!is_array($customValidators)) {
$customValidators = explode(',',$customValidators);
}
if (method_exists($this,$type) && !in_array($type,$invNames)) {
/* built-in validator */
$validated = $this->$type($key,$value,$param);
Expand All @@ -280,7 +282,10 @@ public function validate($key, $value, $type = '')
$validated = true;
}
} else {
$this->modx->log(\modX::LOG_LEVEL_INFO,'[FormIt] Validator "'.$type.'" for field "'.$key.'" was not specified in the customValidators property.');
/* not allowlisted: skip the validator and treat the field as valid, but warn loudly
since LOG_LEVEL_INFO is below MODX's default log_level and would otherwise stay
invisible, making the missing error message look like a bug in FormIt itself */
$this->modx->log(\modX::LOG_LEVEL_WARN,'[FormIt] Validator "'.$type.'" for field "'.$key.'" was skipped because it is not listed in the customValidators property. Add it there (e.g. &customValidators=`'.$type.'`) if it should run.');
$validated = true;
}

Expand Down