Skip to content

Commit c2c45fb

Browse files
committed
chaged validationError constructor
Signed-off-by: Antonio Mendoza Pérez <antmendoza@gmail.com>
1 parent 9c7b9fd commit c2c45fb

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/lib/validation-error.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
1-
import { ErrorObject } from 'ajv';
1+
/*
2+
* Copyright 2021-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* oUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
import { DefinedError } from 'ajv';
219

320
export class ValidationError {
421
readonly message: string;
5-
6-
constructor(readonly error: ErrorObject) {
22+
23+
constructor(readonly error: DefinedError) {
724
this.message = `invalid: ${error.instancePath} | ${error.schemaPath} | ${error.message}`;
825
}
926
}

src/lib/workflow-validator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*/
1717

18-
import { ValidateFunction } from 'ajv';
18+
import { ValidateFunction, DefinedError } from 'ajv';
1919
import { Specification } from './definitions';
2020
import { validators } from './validators';
2121
import { ValidationError } from './validation-error';
@@ -35,7 +35,7 @@ export class WorkflowValidator {
3535
const validateFn = validators.get('Workflow') as ValidateFunction<Specification.Workflow>;
3636
this.isValid = validateFn(this.workflow);
3737
if (validateFn.errors) {
38-
this.errors = validateFn.errors.map((error) => new ValidationError(error));
38+
this.errors = validateFn.errors.map((error) => new ValidationError(error as DefinedError));
3939
}
4040
}
4141
}

0 commit comments

Comments
 (0)