Skip to content

Function: guard()

@kortexya/reasoninglayer


@kortexya/reasoninglayer / 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.

GuardOp

The guard comparison operator.

string | number | boolean

The right-hand value to compare against.

TermInputDto

A TermInputDto for the guard_constraint sort.

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}}
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)),
})