test (filter)
Allows to test some file variables to decide to execute command set.
see also check
parameters
filter: the selector
a string
considered as the extension of the file to match with (equals), or the mimetype to match with (equals or starts with)a string array, as a list of file extensions or mimetypes to match with
a json object, as an conditional expression (logical and combination)
property as a variable
extension: extension of current file
mimetype: mimetype of current file
name: name of current file
basename: name (without extension) of current file
path: relative to san path of the current file
length: length of current file (bytes)
lastmodified: last modified timestamp (unix epoch time) of current file
width: pixel width of current file
height: pixel height of current file
xdpi: horizontal density in dots per inch of current file
ydpi: vertical density in dots per inch of current file
original.extension: extension of original file
original.mimetype: mimetype of original file
original.name: name of original file
original.basename: name (without extension) of original file
original.path: relative to san path of the original file
original.length: length of original file (bytes)
original.lastmodified: last modified timestamp (unix epoch time)
original.width: pixel width of original file
original.height: pixel height of original file
original.xdpi: horizontal density in dots per inch of original file
original.ydpi: vertical density in dots per inch of original file
some new properties has been added in 2023.5 (see below)
Value is the test to be performed, asa simple value, to check if the variable is equal to
Example:"filter": { "extension":"jpg" }
an object, as logical and combination, where property name is an operator and value is the value to used with the operator, or an array of values (logical or combination)
an array, as logical or combination of all items
Example 1:{ "filter": { "extension":["jpg","png"] } }
Example 2:
{ "filter": { "mimetype":["application/pdf",{"startswith":"image/"}] } }
property as a logical operator
or: the value must be an array of conditions
example:and: The value must be an array of conditions.
example:not: the value must be an object (conditional expression)
example:
an array, as a combination table of the above types
Example:Â
some new operators has been added in 2023.5 (see below)
if: action to do if file matches selector
else: action to do if file doen’t match selector
Action can be:
null: means cancel transform execution (do not return any image)
json object or json array: a command set to apply
empty json object or empty json array: continue process
JSON object properties
filter: the file selector
if: action to do file matches the selector
else: action to do file doesn’t match the selector
simplified syntax parameters
Not supported.
array type parameters
[filter]: if matches the filter, continue, else cancel
[filter, action]: if matches the filter, do the action, else cancel
[filter,actionIf,actionElse]: if matches the filter, do the actionIf, else do actionElse
string type parameter
Not supported.
testing variables
2023.5 It is possible to asset variables when present. Variables can also be compared with other variables.
Compare asset variables
To indicate an asset variable, use the prefix asset followed by :
a colon (:) followed by a property name (or a path), or a function property
a period (.) followed by a field name, or a path
a arobace (@) followed by a field name, or a path
A path is field names separated by period (.). It is only possible to access the value of a field by path on the child type.
The value of a non-existent variable is always null.
properties
present: (boolean) to test if asset is present
Example:type: (string) the type of asset
Example:
function properties
type(
name)
: (boolean) test the type of asset, where argument name is a type to test
Example:hasTag(
name)
, where argument name is a tag to test: (boolean) test if asset structurehas taghasField(
name)
, where argument name is a fieldname or a field path: (boolean) test if asset structure has fieldfieldHasTag
( name)
where argument name is a tag to test: (boolean) test if one of the fields of the asset structure has a tag,
field values
Field values are always strings. To compare type values (like dates by example), use field object values.
Examples:
Boolean fields value (nature activated
) are converted to boolean values. Date time values are converted to ISO date time string (yyyy-MM-dd'T'HH:mm:ss"
), and date values to ISO date string.
field object values
To compare typed values, access the field's typed value, but not all field types are supported. Only simple types such as booleans, dates and numbers are supported.
comparing booleans
Use operator test
(or tst
) to compare booleans:
compare dates to now
Use the function now() to compare date to now, with argument as negative day lag (no argument, or any argument that does not matche an integer, means 0 day):
By example, to match asset created before 5 days ago:
By example, to match asset expiring in less than 10 days:
uuid
Use $uuid to specify uuid (also in path).
Comparing variables
To test a variable, specify its name and compare it with a constant, which is always static. For example:
To compare with another variable, specify the name of variable with the pattern ${
name of variable }.
Password fields
Password values are always null.
additional operators
2023.5
blank (or bk): test if string value is blank
oneOf: combinatorial operator whose value is true if only one proposition is true
Example:allOf: combinatorial operator whose value is true if all propositions are true
anyOf: combinatorial operator whose value is true if one of the propositions is true
noneOf: combinatorial operator whose value is true if none of the propositions is true
tst: to compare (equality) boolean values
Â
Â