Last change
on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
739 bytes
|
Line | |
---|
1 | import type {AnySchemaObject} from "../../types"
|
---|
2 | import type {SchemaObjCxt} from ".."
|
---|
3 | import type {JSONType, RuleGroup, Rule} from "../rules"
|
---|
4 |
|
---|
5 | export function schemaHasRulesForType(
|
---|
6 | {schema, self}: SchemaObjCxt,
|
---|
7 | type: JSONType
|
---|
8 | ): boolean | undefined {
|
---|
9 | const group = self.RULES.types[type]
|
---|
10 | return group && group !== true && shouldUseGroup(schema, group)
|
---|
11 | }
|
---|
12 |
|
---|
13 | export function shouldUseGroup(schema: AnySchemaObject, group: RuleGroup): boolean {
|
---|
14 | return group.rules.some((rule) => shouldUseRule(schema, rule))
|
---|
15 | }
|
---|
16 |
|
---|
17 | export function shouldUseRule(schema: AnySchemaObject, rule: Rule): boolean | undefined {
|
---|
18 | return (
|
---|
19 | schema[rule.keyword] !== undefined ||
|
---|
20 | rule.definition.implements?.some((kwd) => schema[kwd] !== undefined)
|
---|
21 | )
|
---|
22 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.