source: trip-planner-front/node_modules/@angular-devkit/schematics/tools/schema-option-transform.js@ 188ee53

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

initial commit

  • Property mode set to 100644
File size: 1.6 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.validateOptionsWithSchema = exports.InvalidInputOptions = void 0;
11const core_1 = require("@angular-devkit/core");
12const rxjs_1 = require("rxjs");
13const operators_1 = require("rxjs/operators");
14class InvalidInputOptions extends core_1.schema.SchemaValidationException {
15 constructor(options, errors) {
16 super(errors, `Schematic input does not validate against the Schema: ${JSON.stringify(options)}\nErrors:\n`);
17 }
18}
19exports.InvalidInputOptions = InvalidInputOptions;
20// This can only be used in NodeJS.
21function validateOptionsWithSchema(registry) {
22 return (schematic, options, context) => {
23 // Prevent a schematic from changing the options object by making a copy of it.
24 options = core_1.deepCopy(options);
25 const withPrompts = context ? context.interactive : true;
26 if (schematic.schema && schematic.schemaJson) {
27 // Make a deep copy of options.
28 return registry.compile(schematic.schemaJson).pipe(operators_1.mergeMap((validator) => validator(options, { withPrompts })), operators_1.first(), operators_1.map((result) => {
29 if (!result.success) {
30 throw new InvalidInputOptions(options, result.errors || []);
31 }
32 return options;
33 }));
34 }
35 return rxjs_1.of(options);
36 };
37}
38exports.validateOptionsWithSchema = validateOptionsWithSchema;
Note: See TracBrowser for help on using the repository browser.