(
schema: S,
options?: {
readonly onNoneEncoding: "omit" | null | undefined
}
)
| 8723 | * |
| 8724 | * @category validation |
| 8725 | * @since 4.0.0 |
| 8726 | */ |
| 8727 | export function isPropertyNames(keySchema: Constraint, annotations?: Annotations.Filter) { |
| 8728 | const propertyNames = toEncoded(keySchema) |
| 8729 | const parser = SchemaParser._issue(propertyNames.ast) |
| 8730 | return makeFilter<object>( |
| 8731 | (input, ast, options) => { |
| 8732 | const keys = Reflect.ownKeys(input) |
| 8733 | const issues: Array<SchemaIssue.Issue> = [] |
| 8734 | for (const key of keys) { |
| 8735 | const issue = parser(key, options) |
| 8736 | if (issue !== undefined) { |
| 8737 | issues.push(new SchemaIssue.Pointer([key], issue)) |
| 8738 | if (options.errors === "first") break |
| 8739 | } |
| 8740 | } |
| 8741 | if (Arr.isArrayNonEmpty(issues)) { |
| 8742 | return new SchemaIssue.Composite(ast, issues, input, options) |
| 8743 | } |
| 8744 | return true |
| 8745 | }, |
| 8746 | { |
| 8747 | expected: "an object with property names matching the schema", |
nothing calls this directly
no test coverage detected
searching dependent graphs…