Expression
class Expression implements Stringable (View source)
Validation expression builder.
Expression Builder implementation for the Mighty Validation Expression Language (mVEL) v1 (v1.*.*).
Constants
| BEHAVIORS |
Expression behaviors. |
| OPERATORS |
Expression operators. |
Properties
| protected string | $buffer | Expression string buffer. |
|
| protected array | $tokens | Expression string buffer tokens. |
Methods
Provides rules and aliases as class methods.
Returns the current expression string.
Adds AND operator (ampersand: &) (default). Ands the next rule/group.
Returns the current expression string.
Adds CLOSE operator (closing parenthesis: )). Ends the current group.
Returns a the passed string as a valid comment.
Writes the passed string to the current expression string buffer.
Returns a valid rule statement from the passed name and arguments.
No description
No description
Groups a set of rules inside a pair of parentheses ().
Writes a macro to the current expression string.
Makes the expression normal (executes all checks). The is the default behavior.
Adds NOT operator (tilde: ~). Negates the next rule/group.
Adds OPEN operator (opening parenthesis: (). Starts a new group.
Makes the expression optimistic (stop checking after first success).
Adds OR operator (pipe: |). Ors the next rule/group.
Makes the expression pessimistic (stop checking after first failure).
Writes a rule to the current expression string.
Returns a the passed key as a valid back-reference injectable.
Writes the passed string to the current expression string buffer.
Adds XOR operator (caret: ^). Xors the next rule/group.
Details
mixed
__call(string $name, array $arguments)
Provides rules and aliases as class methods.
string
__toString()
Returns the current expression string.
Expression
and()
Adds AND operator (ampersand: &) (default). Ands the next rule/group.
string
build()
Returns the current expression string.
Expression
close()
Adds CLOSE operator (closing parenthesis: )). Ends the current group.
static string
comment(string $text)
Returns a the passed string as a valid comment.
Expression
concat(string $string)
Writes the passed string to the current expression string buffer.
Note that the necessary operators will NOT be added automatically (use self::write() instead).
Note that this method may make the expression fail when build if it is malformed.
protected string
createRuleStatement(string $name, array $arguments)
Returns a valid rule statement from the passed name and arguments.
private string
getBehaviorChars()
No description
private array
getOperatorChars()
No description
Expression
group(callable $callback)
Groups a set of rules inside a pair of parentheses ().
Expression
macro(string $macro)
Writes a macro to the current expression string.
Expression
normal()
Makes the expression normal (executes all checks). The is the default behavior.
NOTE: Use this to remove an already added behavior.
Expression
not()
Adds NOT operator (tilde: ~). Negates the next rule/group.
Expression
open()
Adds OPEN operator (opening parenthesis: (). Starts a new group.
Expression
optimistic()
Makes the expression optimistic (stop checking after first success).
NOTE: This has effect only if the expression is not already PESSIMISTIC.
NOTE: Be careful when using OPTIMISTIC with AND or XOR.
Expression
or()
Adds OR operator (pipe: |). Ors the next rule/group.
Expression
pessimistic()
Makes the expression pessimistic (stop checking after first failure).
NOTE: This has effect only if the expression is not already PESSIMISTIC.
NOTE: Be careful when using PESSIMISTIC with OR or XOR.
Expression
rule(string $rule)
Writes a rule to the current expression string.
static string
variable(string $key)
Returns a the passed key as a valid back-reference injectable.
Expression
write(string $string)
Writes the passed string to the current expression string buffer.
Note that the necessary operators will be added automatically.
Expression
xor()
Adds XOR operator (caret: ^). Xors the next rule/group.