Example of creating a new custom expression (advanced)

To see the potential of custom expression (advanced) function we leave you here an example of how to use it.

 Go to definitions tab where you can set an audit by clicking on the add new button.

A new form displays on your screen with four main boxes to set: audit basic data, audit scheduler configuration, dam query, audit rule check list, and definition-specific metadata role settings. We described these boxes in another article. After filling them in continue setting a custom expression as described in the next step.

 Choose the custom expression (advanced) function in check type field.

The example is the following: we want to know if the height (in pixels) of every asset is bigger than its width (in pixels). If it is, then the height has to be equal to 5000, if not the width needs to be equal to 5000.

Fill in the expression, comparison, value, and check error message fields as it follows:

HINT: You can use expressions also in "value" field to get even more flexibility when defining your audit check.

Click on save button at the bottom. Now your audit is set and it is visible on the home page.

Below you can find other methods that can be used in this function.

Methods supported:

  • asset.getMetadataValue('<metadata name>')
    • <metadata name> can be checked in Metadata list in Veriflies, in general it is same label as reported by DAM
    • NOTICE: Some metadata reported might have some other string as beginning - examples: "File properties: Height" or "File properties: Aspect ratio" etc
  • validator.evaluateOriginalAsset('<check name>') / validator.evaluatePreview('<check name>')
    • performs evaluation of various technical & content analysis checks over original asset or preview; returns evaluated value - for example in case of Color Space check it might be something like "RGB"
    • list of checks is attached below
  • validator.performTechnicalControlOnOriginalAsset('<technical control name>') / validator.performTechnicalControlOnPreview('<technical control name>')
    • performs technical control over original asset / preview and returns boolean value which is result of the validation
    • <technical control name> is name registered in Parameters > Technical Controls section

Operators available:

* / + - > >= <=

INFO: ternary operator ( <condition> ? 'true' : 'false') is also available

ADDITIONAL INFO: more reference of Expression Syntax can be found here: https://symfony.com/doc/current/components/expression_language/syntax.html

Examples of expressions:

* asset.getMetadataValue('File properties: Height') * asset.getMetadataValue('File properties: Width')

* asset.getMetadataValue('File properties: Height') > asset.getMetadataValue('File properties: Width') ? asset.getMetadataValue('File properties: Height') : asset.getMetadataValue('File properties: Width')

* asset.getMetadataValue('File properties: Height') > 500 && asset.getMetadataValue('File properties: Width') > 500 ? 'true' : 'false'

List of available checks (names to be used in expressions):

  • FILE_EXTENSION_CHECK
  • FILE_SIZE_CHECK
  • MIME_TYPE_CHECK
  • DIMENSION_WIDTH_CHECK
  • DIMENSION_HEIGHT_CHECK
  • DIMENSION_RATIO_CHECK
  • COLOR_SPACE_CHECK
  • COLOR_PROFILE_CHECK
  • BACKGROUND_COLOR_CHECK
  • BLUR_LEVEL_PERCENTAGE_CHECK
  • SCENE_POSITION_HORIZONTAL_CHECK
  • SCENE_POSITION_VERTICAL_CHECK
  • SCENE_SIZE_PERCENTAGE_CHECK
  • BACKGROUND_TRANSPARENCY_CHECK

Those checks are strictly connected to checks available in Technical Controls, you can refer there to get more information about their meaning and behavior.