Skip to content
中文

BreakEvent ​

CORE · interface · Type contract

Diagnostic metadata only; rule inputs and request data are not included.

Import ​

ts
import type { BreakEvent } from '@jangts/agent-core/support';
js
/** @typedef {import('@jangts/agent-core/support').BreakEvent} BreakEvent */

Other public entry points:@jangts/agent-core, @jangts/agent-core/types, @jangts/agent-core/structs, @jangts/agent-core/support.

Definition ​

ts
interface BreakEvent

Field structure ​

FieldTypeRequiredDescription
errorunknownRequiredRead-only. The thrown value, kept for identity.
tagsreadonly string[]RequiredRead-only. Tags of the check that rejected, plus its enclosing group tags.

Examples ​

One explicit rejection ​

Beginner · Node.js

ts
import { Support } from '@jangts/agent-core';
const input = '你好';
Support.breakWhile(!input.trim(), '问题不能为空');
console.log(input);
js
import { Support } from '@jangts/agent-core';
const input = '你好';
Support.breakWhile(!input.trim(), '问题不能为空');
console.log(input);

Checks with dependencies evaluated in order ​

Configuration · Node.js

ts
import { Support } from '@jangts/agent-core';
const input: unknown = { name: 'Ivan' };
Support.breakWhile([
  { occur: !input || typeof input !== 'object', error: '需要对象' },
  { occur: () => !('name' in (input as object)), error: '缺少 name' },
]);
console.log(input);
js
import { Support } from '@jangts/agent-core';
const input = { name: 'Ivan' };
Support.breakWhile([
    { occur: !input || typeof input !== 'object', error: '需要对象' },
    { occur: () => !('name' in input), error: '缺少 name' },
]);
console.log(input);

API reference, usage examples and developer guides.