MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / matchRequiredFields

Function matchRequiredFields

packages/parser/src/sniffer.ts:49–56  ·  view source on GitHub ↗

* 检查必需字段是否存在

(headContent: string, fields: string[])

Source from the content-addressed store, hash-verified

47 * 检查必需字段是否存在
48 */
49function matchRequiredFields(headContent: string, fields: string[]): boolean {
50 // 简单检查:字段名是否出现在文件头中
51 // 对于 JSON 文件,检查 "fieldName" 是否存在
52 return fields.every((field) => {
53 const pattern = new RegExp(`"${field.replace('.', '"\\s*:\\s*.*"')}"\\s*:`)
54 return pattern.test(headContent) || headContent.includes(`"${field}"`)
55 })
56}
57
58/**
59 * 格式嗅探器

Callers 1

matchFeatureMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected