Skip to content

Function: guard()

@kortexya/reasoninglayer


@kortexya/reasoninglayer / guard

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

op

GuardOp

The guard comparison operator.

The right-hand value to compare against.

string | number | boolean

Returns

TermInputDto

A TermInputDto for the guard_constraint sort.

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

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