Skip to content

Expressions

In this section, you will learn more about Beatrix Expressions. Below are the main details of this powerful resource for obtaining constant and dynamic values for use in your YAML model.

As you know, we use the YAML language as an interpretation engine to build the code for your Solution. In certain sections of the YAML, it is necessary to obtain dynamic values to be used in validation rules or entity rules, such as: obtaining the current date, adding days to a certain date, set a constant value to an entity property, among others. To make this possible, in a flexible way, we created the Beatrix Expressions. Beatrix Expressions purpose is to obtain any type of desired value through functions with parameters, be it a constant or calculated at run time.

In short, an Expression is a flexible and standardized way for our robots to interpret the types of values desired and then generate healthy, reliable and functional source code.

General Rules

  • Every expression requires that at least one parameter be defined. See Parameters section for more details;
  • For expressions that require more than one parameter, they must be separated by ','

Find out below the types of Expressions that exist and the rules for using each one.

Value()

This is the most generic of the Expressions. Its purpose is to return a certain value according to the type of Parameter informed.

Requirements Rules:

  • Only one parameter is allowed;
  • The parameter must exist and be valid;
  • Allows any parameter of the types listed here

Examples:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Returns the constant string "My_Value":
Value(@ConstString::My_Value)

# Returns the constant number 10 in Int32 type:
Value(@ConstInt::10)

# Returns the appropriate source code to obtain the current date in UTC format:
Value(@UtcToday) 

# Returns the appropriate source code to obtain the value for the specified property name:
Value(@Prop::My_First_Property)

Tip

See the Parameters examples to learn more possibilities of use this Expression.

DateAddDays()

The purpose of this Expression is to add a number of days to the specified date.

Requirements Rules:

  • Two parameters are needed, they are:
    • The date you want to add the days. The allowed params are: @ConstDate; @UtcNow; @UtcToday
    • The number of days you want to add to the date. The allowed params are: @ConstInt; @ConstDouble
  • The parameters must exist and be valid

Examples:

1
2
3
4
5
# Returns the appropriate source code to add 10 days to the current date:
DateAddDays(@UtcToday,@ConstInt::10)

# Returns the appropriate source code to add 20 days to a constant date:
DateAddDays(@ConstDate::2022-01-01::yyyy-MM-dd,@ConstDouble::20)


ValInstance()

This Expression must only be used in EntityValidations section, for the PropertyValidation type. It returns an instance for the specified validation object, allowing this validation to be performed within another validation.

You must enter as a parameter the name of the validation you want to obtain the instance.

Requirements Rules:

  • Only one parameter of type @ConstString is allowed;
  • The name of validation must exist in the EntityValidations list, in the current model;
  • The parent validation property must be a relationship to the entity of this validation object

Example:

1
2
# Returns the appropriate source code to obtain the validation object instance:
ValInstance(@ConstString::My_Second_EntityValidation)


Back to top