Function: guard()
@kortexya/reasoninglayer / guard
Function: guard()
Section titled “Function: guard()”guard(
op,right):TermInputDto
Defined in: src/builders/guard.ts:40
Create a guard constraint as a TermInputDto.
Produces a TermInputDto representing the guard_constraint meta-sort
with op and right features.
This is a shorthand for the most common constrained variable pattern.
Parameters
Section titled “Parameters”The guard comparison operator.
string | number | boolean
The right-hand value to compare against.
Returns
Section titled “Returns”A TermInputDto for the guard_constraint sort.
Remarks
Section titled “Remarks”Serialization format: Untagged (TermInputDto). Used as the constraint argument
to constrained().
This function constructs object literals directly matching the TermInputDto and
FeatureInputValueDto shapes. It does NOT import from other builder files.
The produced JSON matches:
{"sort_name": "guard_constraint", "features": {"op": "gt", "right": 100}}Example
Section titled “Example”import { psi, constrained, guard } from '@kortexya/reasoninglayer';
// Use with constrained():const salary = constrained("?Salary", guard("gt", 100));
// In a rule:psi("employee", { salary: constrained("?Salary", guard("gt", 100)),})