protected function FeedsExJmesPath::validateExpression in Feeds extensible parsers 7
Same name and namespace in other branches
- 7.2 src/FeedsExJmesPath.inc \FeedsExJmesPath::validateExpression()
Validates an expression.
Parameters
string &$expression: The expression to validate.
Return value
string|null Return the error string, or null if validation was passed.
Overrides FeedsExBase::validateExpression
File
- src/
FeedsExJmesPath.inc, line 225 - Contains FeedsExJmesPath.
Class
- FeedsExJmesPath
- Parses JSON documents with JMESPath.
Code
protected function validateExpression(&$expression) {
$expression = trim($expression);
if (!strlen($expression)) {
return;
}
try {
$this
->search($expression, array());
} catch (SyntaxErrorException $e) {
// Remove newlines after nl2br() to make testing easier.
return str_replace("\n", '', nl2br(check_plain(trim($e
->getMessage()))));
} catch (Exception $e) {
// This is a problem executing the query, which we don't worry about.
}
}