Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Expression.php

class Expression

Same name in this branch
  1. 11.1.x vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php \PhpParser\Node\Stmt\Expression
  2. 11.1.x vendor/phpdocumentor/type-resolver/src/Types/Expression.php \phpDocumentor\Reflection\Types\Expression

Validates a value using an expression from the Expression Language component.

@author Fabien Potencier <fabien@symfony.com> @author Bernhard Schussek <bschussek@gmail.com>

Hierarchy

  • class \Symfony\Component\Validator\Constraint
    • class \Symfony\Component\Validator\Constraints\Expression extends \Symfony\Component\Validator\Constraint

Expanded class hierarchy of Expression

See also

https://symfony.com/doc/current/components/expression_language.html

35 string references to 'Expression'
ArrayExpression::setElements in vendor/mck89/peast/lib/Peast/Syntax/Node/ArrayExpression.php
Sets array elements
ArrowFunctionExpression::setBody in vendor/mck89/peast/lib/Peast/Syntax/Node/ArrowFunctionExpression.php
Sets the function body
AssignmentExpression::setLeft in vendor/mck89/peast/lib/Peast/Syntax/Node/AssignmentExpression.php
Sets the left node of the assignment
BinaryExpression::setLeft in vendor/mck89/peast/lib/Peast/Syntax/Node/BinaryExpression.php
Sets the left expression
CallExpression::setArguments in vendor/mck89/peast/lib/Peast/Syntax/Node/CallExpression.php
Sets the arguments array

... See full list

File

vendor/symfony/validator/Constraints/Expression.php, line 27

Namespace

Symfony\Component\Validator\Constraints
View source
class Expression extends Constraint {
    public const EXPRESSION_FAILED_ERROR = '6b3befbc-2f01-4ddf-be21-b57898905284';
    protected const ERROR_NAMES = [
        self::EXPRESSION_FAILED_ERROR => 'EXPRESSION_FAILED_ERROR',
    ];
    public string $message = 'This value is not valid.';
    public string|ExpressionObject|null $expression = null;
    public array $values = [];
    public bool $negate = true;
    
    /**
     * @param string|ExpressionObject|array<string,mixed>|null $expression The expression to evaluate
     * @param array<string,mixed>|null                         $values     The values of the custom variables used in the expression (defaults to an empty array)
     * @param string[]|null                                    $groups
     * @param array<string,mixed>                              $options
     * @param bool|null                                        $negate     Whether to fail if the expression evaluates to true (defaults to false)
     */
    public function __construct(string|ExpressionObject|array|null $expression, ?string $message = null, ?array $values = null, ?array $groups = null, mixed $payload = null, array $options = [], ?bool $negate = null) {
        if (!class_exists(ExpressionLanguage::class)) {
            throw new LogicException(\sprintf('The "symfony/expression-language" component is required to use the "%s" constraint. Try running "composer require symfony/expression-language".', __CLASS__));
        }
        if (\is_array($expression)) {
            $options = array_merge($expression, $options);
        }
        else {
            $options['value'] = $expression;
        }
        parent::__construct($options, $groups, $payload);
        $this->message = $message ?? $this->message;
        $this->values = $values ?? $this->values;
        $this->negate = $negate ?? $this->negate;
    }
    public function getDefaultOption() : ?string {
        return 'expression';
    }
    public function getRequiredOptions() : array {
        return [
            'expression',
        ];
    }
    public function getTargets() : string|array {
        return [
            self::CLASS_CONSTRAINT,
            self::PROPERTY_CONSTRAINT,
        ];
    }
    public function validatedBy() : string {
        return 'validator.expression';
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
Constraint::$groups public property The groups that the constraint belongs to.
Constraint::$payload public property Domain-specific data attached to a constraint.
Constraint::addImplicitGroupName public function Adds the given group if this constraint is in the Default group. 2
Constraint::CLASS_CONSTRAINT public constant Marks a constraint that can be put onto classes.
Constraint::DEFAULT_GROUP public constant The name of the group given to all constraints with no explicit group.
Constraint::getErrorName public static function Returns the name of the given error code.
Constraint::normalizeOptions protected function
Constraint::PROPERTY_CONSTRAINT public constant Marks a constraint that can be put onto properties.
Constraint::__get public function Returns the value of a lazily initialized option. 2
Constraint::__isset public function 1
Constraint::__set public function Sets the value of a lazily initialized option. 1
Constraint::__sleep public function Optimizes the serialized value to minimize storage space.
Expression::$expression public property
Expression::$message public property
Expression::$negate public property
Expression::$values public property
Expression::ERROR_NAMES protected constant Maps error codes to the names of their constants. Overrides Constraint::ERROR_NAMES
Expression::EXPRESSION_FAILED_ERROR public constant
Expression::getDefaultOption public function Returns the name of the default option. Overrides Constraint::getDefaultOption
Expression::getRequiredOptions public function Returns the name of the required options. Overrides Constraint::getRequiredOptions
Expression::getTargets public function Returns whether the constraint can be put onto classes, properties or
both.
Overrides Constraint::getTargets
Expression::validatedBy public function Returns the name of the class that validates this constraint. Overrides Constraint::validatedBy
Expression::__construct public function Overrides Constraint::__construct
RSS feed
Powered by Drupal