Return ajv errors from validate method.

This commit is contained in:
Austin Smith
2025-11-19 08:33:39 -05:00
parent c8d52f15cc
commit 4d1a652e84
2 changed files with 3 additions and 3 deletions

View File

@@ -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> {

View File

@@ -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);
}); });
}); });