@onzag/itemize / Modules / base/Root/Module/ItemDefinition/ConditionalRuleSet / default
base/Root/Module/ItemDefinition/ConditionalRuleSet.default
This class provides conditional rule sets that are set for an specific situation to take place, it has multiple uses like disabling an item, or making a property a certain value conditional rule sets are chainable and represents rules based on properties or items
for example say we have an item vehicle and which one is motorbike and a motorbike might have a belt, chain or shaft lets say we also decided to add a property drive-type to the vehicle class
So we make a rule for this
{
"name": "belt",
"excludedIf": {
"property": "type",
"comparator": "not-equal",
"value": "motorbike",
"gate": "or",
"condition": {
"property": "drive-type",
"comparator": "not-equal",
"value": {
"exactValue": "belt-drive"
}
}
}
}
Conditional rule sets are chainable and might also include components, components are the same as items, for example
{
"name": "belt-keeper",
"excludedIf": {
"component": "belt",
"isIncluded": false
}
}
This means that the belt-keeper item is not available if there is no such thing as a belt included
Rule sets are also available for things like properties, whether they are available or not, default values, might exclusions, etc... they are very practical, but limited on purpose to avoid excessive complexity
• new default(rawJSON, parentModule, parentItemDefinition, parentPropertyDefinition, parentInclude): default
Constructor
| Name | Type | Description |
|---|---|---|
rawJSON |
IConditionalRuleSetRawJSONDataType |
the raw data as JSON |
parentModule |
default |
the module where this node is located |
parentItemDefinition |
default |
the item definition that this node is |
parentPropertyDefinition |
default |
the property definition that contains the rule located, it might not be available for example for condition in prop extensions |
parentInclude |
default |
the item that contains this condition, such as in exclusion rules, it might not be available as well |
base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:208
• Private conditions: default[]
an internal condition for nested conditions
base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:195
• parentInclude: default
a parent include, if available, might be null
base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:186
• parentItemDefinition: default
the item definition where it is contained
base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:178
• parentModule: default
the parent module of this condition
base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:174
• parentPropertyDefinition: default
the property that it is contained within, might be null for prop extensions
base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:182
• rawData: IConditionalRuleSetRawJSONDataType
the raw data that was used to generate this conditional rule set
base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:190
▸ evaluate(id, version): boolean
Evaluates the result of the conditional value as this current point as defined by the item defintion
| Name | Type | Description |
|---|---|---|
id |
string |
the id to be used to retrieve values for properties during evaluation |
version |
string |
the version used to retrieve values as well |
boolean
a boolean on whether the conditional rule set passes or not
base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:243