1
0

feat: ValueMatcher 支持 primitive 原始值简写,等价于 { equals: value }

This commit is contained in:
2026-05-19 17:07:47 +08:00
parent 8d8549d07f
commit 12cd05b04e
37 changed files with 1836 additions and 1022 deletions

View File

@@ -1,4 +1,4 @@
import type { ContentRules, ValueMatcher } from "../../expect/types";
import type { ContentRules, ValueMatcherInput } from "../../expect/types";
import type { ResolvedTargetBase } from "../../types";
export interface ResolvedTcpConfig {
@@ -27,7 +27,7 @@ export interface TcpDefaultsConfig {
export interface TcpExpectConfig {
banner?: ContentRules;
connected?: boolean;
durationMs?: ValueMatcher;
durationMs?: ValueMatcherInput;
}
export interface TcpTargetConfig {

View File

@@ -3,6 +3,7 @@ import { isNumber, isPlainObject, isString } from "es-toolkit";
import type { ConfigValidationIssue } from "../../schema/issues";
import type { CheckerValidationInput } from "../types";
import { normalizeExpectMatchers } from "../../expect/normalize";
import { validateContentRules, validateValueMatcher } from "../../expect/validate-matcher";
import { issue, joinPath } from "../../schema/issues";
@@ -75,6 +76,8 @@ function validateTcpExpect(
const issues: ConfigValidationIssue[] = [];
const expectPath = joinPath(path, "expect");
normalizeExpectMatchers(expect, ["durationMs"]);
if (expect["connected"] !== undefined && typeof expect["connected"] !== "boolean") {
issues.push(issue("invalid-type", joinPath(expectPath, "connected"), "必须为布尔值", targetName));
}