source: imaps-frontend/node_modules/ajv/lib/compile/validate/applicability.ts@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • 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.