Filters allow the values represented by identifiers to be processed prior to specification evaluation. For example:
foo|upper is "ABC" // convert foo to uppercase before comparison.
foo|lower|trim is "abc" // trim whitespace, then convert foo to lowercase before comparison.
Filters are made available via the Comparison node by way of the Identifier node. When a filter applies to an Identifier node, it is present on the root identifier only and is considered to apply to the whole thing.
Specifications must be responsible for applying filters since they have the job of extracting a value for a given identifier. This should therefore be as simple as possible to minimise the burden:
public function isSatisfiedBy($value) : bool
{
if (!$value instanceof User) {
return false;
}
$value = $this->filters->apply($value->getUsername());
// ...
}
There is no need to allow filters to apply to Literal nodes since they can be written in the required format in the first place.
Filters allow the values represented by identifiers to be processed prior to specification evaluation. For example:
Filters are made available via the
Comparisonnode by way of theIdentifiernode. When a filter applies to anIdentifiernode, it is present on the root identifier only and is considered to apply to the whole thing.Specifications must be responsible for applying filters since they have the job of extracting a value for a given identifier. This should therefore be as simple as possible to minimise the burden:There is no need to allow filters to apply to
Literalnodes since they can be written in the required format in the first place.