Skip to content

API: Rules

The rules system provides dynamic behavior through condition-action pairs. When a condition evaluates to true, the associated action is applied.

FormFieldRule

Class Signature

Conditions

RuleCondition

abstract

Class Signature

All conditions extend RuleCondition.


ScalarCondition

abstract

Class Signature

Scalar conditions (operating on a single field) extend ScalarCondition.


BooleanCondition

Class Signature

Schema: vyuh.form.condition.boolean

dart
enum BooleanOperator { isTrue, isFalse }

StringCondition

Class Signature

Schema: vyuh.form.condition.string

dart
enum StringOperator {
  equals, notEquals, contains, notContains,
  startsWith, endsWith, matches, isEmpty, isNotEmpty
}

NumericCondition

Class Signature

Schema: vyuh.form.condition.numeric

dart
enum NumericOperator {
  equal, greaterThan, lessThan, greaterEqual, lessEqual, between
}

DateCondition

Class Signature

Schema: vyuh.form.condition.date

dart
enum DateOperator { before, after, on, between }

EmptyCondition

Class Signature

Schema: vyuh.form.condition.empty

Checks for null, empty string, empty list, or empty map.


CompoundCondition

Class Signature

Schema: vyuh.form.condition.compound

Combines multiple conditions with AND/OR logic.

dart
enum ConditionOperator { and, or }

Actions

RuleAction

abstract

Class Signature

All actions extend RuleAction.


VisibilityAction

Class Signature

Schema: vyuh.form.action.visibility

Controls field visibility.

showWhenTrueCondition MetCondition Not Met
trueShowHide
falseHideShow

EnabledAction

Class Signature

Schema: vyuh.form.action.enabled

Controls field enabled/disabled state.


SetValueAction

Class Signature

Schema: vyuh.form.action.setValue

Sets a field value when the condition is met.


FocusAction

Class Signature

Schema: vyuh.action.focus

Moves focus to a target field.


ValidationAction

Class Signature

Schema: vyuh.action.validation

Adds or removes a validation dynamically via DynamicValidator.


CompoundAction

Class Signature

Schema: vyuh.action.compound

Applies multiple actions together.

When DSL

The When class provides fluent condition creation:

String Conditions

dart
When.fieldEquals(String field, String value, {bool caseSensitive = false})
When.fieldNotEquals(String field, String value, {bool caseSensitive = false})
When.fieldContains(String field, String value, {bool caseSensitive = false})
When.fieldEmpty(String field)
When.fieldNotEmpty(String field)

Boolean Conditions

dart
When.fieldTrue(String field)
When.fieldFalse(String field)

Compound Conditions

dart
When.allOf(List<When> conditions)  // AND
When.anyOf(List<When> conditions)  // OR

Actions

dart
When.fieldEquals('type', 'paid').show()     // VisibilityAction(showWhenTrue: true)
When.fieldEquals('type', 'paid').hide()     // VisibilityAction(showWhenTrue: false)
When.fieldEquals('type', 'paid').enable()   // EnabledAction(enableWhenTrue: true)
When.fieldEquals('type', 'paid').disable()  // EnabledAction(enableWhenTrue: false)

Next Steps