source: trip-planner-front/node_modules/@angular-devkit/core/src/json/schema/schema.js@ 6a80231

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

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.mergeSchemas = exports.isJsonSchema = void 0;
11const interface_1 = require("../interface");
12function isJsonSchema(value) {
13 return interface_1.isJsonObject(value) || value === false || value === true;
14}
15exports.isJsonSchema = isJsonSchema;
16/**
17 * Return a schema that is the merge of all subschemas, ie. it should validate all the schemas
18 * that were passed in. It is possible to make an invalid schema this way, e.g. by using
19 * `mergeSchemas({ type: 'number' }, { type: 'string' })`, which will never validate.
20 * @param schemas All schemas to be merged.
21 */
22function mergeSchemas(...schemas) {
23 return schemas.reduce((prev, curr) => {
24 if (curr === undefined) {
25 return prev;
26 }
27 if (prev === false || curr === false) {
28 return false;
29 }
30 else if (prev === true) {
31 return curr;
32 }
33 else if (curr === true) {
34 return prev;
35 }
36 else if (Array.isArray(prev.allOf)) {
37 if (Array.isArray(curr.allOf)) {
38 return { ...prev, allOf: [...prev.allOf, ...curr.allOf] };
39 }
40 else {
41 return { ...prev, allOf: [...prev.allOf, curr] };
42 }
43 }
44 else if (Array.isArray(curr.allOf)) {
45 return { ...prev, allOf: [prev, ...curr.allOf] };
46 }
47 else {
48 return { ...prev, allOf: [prev, curr] };
49 }
50 }, true);
51}
52exports.mergeSchemas = mergeSchemas;
Note: See TracBrowser for help on using the repository browser.