Return ajv errors from validate method.
This commit is contained in:
@@ -2,6 +2,7 @@ import Ajv, { type ValidateFunction } from 'ajv';
|
|||||||
import addFormats from 'ajv-formats';
|
import addFormats from 'ajv-formats';
|
||||||
|
|
||||||
const ajv = new Ajv({
|
const ajv = new Ajv({
|
||||||
|
allErrors: true,
|
||||||
coerceTypes: true,
|
coerceTypes: true,
|
||||||
});
|
});
|
||||||
addFormats(ajv);
|
addFormats(ajv);
|
||||||
@@ -239,7 +240,7 @@ export class Declaform extends HTMLElement {
|
|||||||
}
|
}
|
||||||
const obj = this.toObject();
|
const obj = this.toObject();
|
||||||
const isValid = this._validate(obj);
|
const isValid = this._validate(obj);
|
||||||
return isValid;
|
return this._validate.errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async hydrateFromEndpoint(endpoint: string): Promise<void> {
|
private async hydrateFromEndpoint(endpoint: string): Promise<void> {
|
||||||
|
|||||||
@@ -152,8 +152,7 @@ describe('Declaform', () => {
|
|||||||
await form.ready;
|
await form.ready;
|
||||||
const isValid = await form.validate();
|
const isValid = await form.validate();
|
||||||
|
|
||||||
expect(isValid).toBe(false);
|
expect(isValid).not.toBe(true);
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user