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
abstractClass Signature
All conditions extend RuleCondition.
ScalarCondition
abstractClass Signature
Scalar conditions (operating on a single field) extend ScalarCondition.
BooleanCondition
Class Signature
Schema: vyuh.form.condition.boolean
enum BooleanOperator { isTrue, isFalse }StringCondition
Class Signature
Schema: vyuh.form.condition.string
enum StringOperator {
equals, notEquals, contains, notContains,
startsWith, endsWith, matches, isEmpty, isNotEmpty
}NumericCondition
Class Signature
Schema: vyuh.form.condition.numeric
enum NumericOperator {
equal, greaterThan, lessThan, greaterEqual, lessEqual, between
}DateCondition
Class Signature
Schema: vyuh.form.condition.date
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.
enum ConditionOperator { and, or }Actions
RuleAction
abstractClass Signature
All actions extend RuleAction.
VisibilityAction
Class Signature
Schema: vyuh.form.action.visibility
Controls field visibility.
showWhenTrue | Condition Met | Condition Not Met |
|---|---|---|
true | Show | Hide |
false | Hide | Show |
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
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
When.fieldTrue(String field)
When.fieldFalse(String field)Compound Conditions
When.allOf(List<When> conditions) // AND
When.anyOf(List<When> conditions) // ORActions
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
- FormBuilder -- DSL API
- Editor -- Editor API
- Validations -- Validation types