source: trip-planner-front/node_modules/ajv/lib/compile/validate/applicability.ts@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 739 bytes
Line 
1import type {AnySchemaObject} from "../../types"
2import type {SchemaObjCxt} from ".."
3import type {JSONType, RuleGroup, Rule} from "../rules"
4
5export 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
13export function shouldUseGroup(schema: AnySchemaObject, group: RuleGroup): boolean {
14 return group.rules.some((rule) => shouldUseRule(schema, rule))
15}
16
17export 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.