diff --git a/packages/declaform/src/index.ts b/packages/declaform/src/index.ts index 66ec355..aea96ef 100644 --- a/packages/declaform/src/index.ts +++ b/packages/declaform/src/index.ts @@ -2,6 +2,7 @@ import Ajv, { type ValidateFunction } from 'ajv'; import addFormats from 'ajv-formats'; const ajv = new Ajv({ + allErrors: true, coerceTypes: true, }); addFormats(ajv); @@ -239,7 +240,7 @@ export class Declaform extends HTMLElement { } const obj = this.toObject(); const isValid = this._validate(obj); - return isValid; + return this._validate.errors; } private async hydrateFromEndpoint(endpoint: string): Promise { diff --git a/packages/declaform/tests/declaform.test.ts b/packages/declaform/tests/declaform.test.ts index ff6b3e6..9a3302f 100644 --- a/packages/declaform/tests/declaform.test.ts +++ b/packages/declaform/tests/declaform.test.ts @@ -152,8 +152,7 @@ describe('Declaform', () => { await form.ready; const isValid = await form.validate(); - expect(isValid).toBe(false); - + expect(isValid).not.toBe(true); }); });