kConditionsEditor takes over a <textarea> and puts a nested
condition builder in its place. Every change writes portable JSON straight back
into the textarea, so your form posts exactly as it always did — and the
evaluator SDKs turn that JSON into a boolean anywhere else in your stack.
This is a contact-form rule. Press Edit Conditions, build something, and watch the JSON and the live evaluation below react. View source is switched on here, so you can also see the generated SQL.
Swap the look without losing the rule — or see all five on the Skins page.
—
—
Same editor, output: 'sql'. This one is pointed at a textarea that
already accepts SQL — the case where you want to give people who do not write SQL a
friendlier way to fill in a field they could otherwise only type into. The field is
left visible on purpose, so they can see what is being written for them.
documentInComment: true tucks the rule into a trailing comment, so this
one field round-trips: reload the page, and the builder reads its own state back out
of the SQL. Change the dialect to watch it regenerate.
The editor knows your fields, which operators each one accepts, and which fields may be compared against which. It emits a document that describes the rule and nothing else — no functions, no closures.
Pass the document and a flat set of field values to an SDK and get
true or false back. The JS and PHP SDKs run the same
34 conformance fixtures, so they agree by construction.
<link rel="stylesheet" href="src/k-conditions-editor.css">
<textarea id="conditions" name="conditions"></textarea>
<script src="src/k-conditions-evaluator.js"></script>
<script src="src/k-conditions-editor.js"></script>
<script>
KConditionsEditor.attach('#conditions', {
emptyText: 'Always',
fields: [
{ name: 'name', label: 'Name', type: 'text' },
{ name: 'dob', label: 'Date of Birth', type: 'date' },
{ name: 'state', label: 'State', type: 'enum',
choices: ['Florida', 'Texas', 'California'] }
]
});
</script>
Then, on the server:
use function Kastrack\ConditionsEditor\evaluate;
if (evaluate($_POST['conditions'], $submission)) {
// do the thing
}
"Is this email already registered?" can only be answered on the server. Mark the
operator availableIn: ["server"] with a client: "skip"
policy, and the same rule pre-checks everything else in the browser without ever
blocking the submit — then evaluates in full on the server.
A skipped condition behaves as though it were never in the document. Its siblings
decide the group; a group left with no children drops out of its own parent. A
skipped condition can never turn an OR true on its own.
Any value slot can point at another field instead of a literal.
comparableWith narrows that list per field — by name, by
type:, by group:, or false to switch it off.
Pass a function as the last argument to any SDK entry point and it receives the original arguments plus the result and the details, and its return value becomes the return value. Useful for logging what got deferred.