Skip to content

Context Rules

The rules section allows you to define the business rules logic that will be applied to the current Context.

Each rule in this section is always executed in a context plus an execution order. The execution order follows the rule position at the collection of rules you created. The generated order by Beatrix is always every 10 positions (10, 20, 30...), which allows you to create new classes of business rules in these intervals.

Fields

A context rule contains the following fields to be defined:

Name

The name of context rule to be created.

Requirements Rules:

  • Is Required;
  • Must not be a Reserved Keyword;
  • Must start with a letter;
  • Must contains only letters, numbers and the underline char ('_');
  • Max length of 50 chars

Example:

1
2
Rules:
- Name: Set_Status_Field


Type

The type of context rule to be created.

Possible types are:

  • EntityRule: Allows to use a Entity Rule in this context and execution order;
  • WriteOperationRule: Performs the database data persistence;
  • ReadOperationRule: Performs the database data reading;
  • BlankRule: Creates a blank rule class, in this context and execution order, for you to place your customized business rule logic, avoiding conflicts in future merges;

Requirements Rules:

  • Is Required;
  • Must be an Allowed valid type, according to the types informed above;
  • Must be Allowed for current context:
    • If EntityRule, it's allowed only following contexts: Create, Update and UpdatePartial;
    • If WriteOperationRule, it's allowed only following contexts: Create, Update, UpdatePartial and Delete;
    • If ReadOperationRule, it's allowed only following contexts: ReadAll, and ReadByKey;
    • If BlankRule, it's allowed for all available contexts

Example:

1
2
3
Rules:
- Name: Set_Status_Field
  Type: EntityRule


Order

Specifies the order in which this business rule class will be performed on the rule pipeline within the current context.

Requirements Rules:

  • Is Required;
  • Must be in the range between 1 and 300;
  • Each rule class must have its unique order for the current context

Example:

1
2
3
4
Rules:
- Name: Set_Status_Field
  Type: EntityRule
  Order: 1

Tip: Keep a gap between the rule classes so that it is possible to add new classes between the orders already defined without having to reorder them.


ExecRuleName

The name of business rule in current model that not belongs to a context and execution order, for example: EntityRule.

This field allows you to link another business rule logic to be performed in the current context and execution order.

Requirements Rules:

If EntityRule type:

  • Is Required;
  • The name must exist in EntityRule list in the current model

If WriteOperationRule, ReadOperationRule or BlankRule type:

  • Must not be filled

Example:

1
2
3
4
5
Rules:
- Name: Set_Status_Field
  Type: EntityRule
  Order: 1
  ExecRuleName: My_First_EntityRule


Back to top