diff --git a/packages/form-core/test/validate/Validator.test.js b/packages/form-core/test/validate/Validator.test.js index b24abc89c..787c074fc 100644 --- a/packages/form-core/test/validate/Validator.test.js +++ b/packages/form-core/test/validate/Validator.test.js @@ -48,7 +48,7 @@ describe('Validator', () => { it('throws when executing a Validator without a name', async () => { class MyValidator extends Validator {} expect(() => { - new MyValidator().execute(); + new MyValidator().execute(undefined); }).to.throw( 'A validator needs to have a name! Please set it via "static get validatorName() { return \'IsCat\'; }"', ); @@ -61,7 +61,10 @@ describe('Validator', () => { } } - const vali = new MyValidator({}, { getMessage: 'This is the custom error message' }); + const vali = new MyValidator( + {}, + { getMessage: async () => 'This is the custom error message' }, + ); const { getMessage } = getProtectedMembers(vali); await expectThrowsAsync( @@ -76,8 +79,8 @@ describe('Validator', () => { }); it('receives a config object (optionally) as a second argument on instantiation', async () => { - const vali = new Validator('myParam', { my: 'config' }); - expect(vali.config).to.eql({ my: 'config' }); + const vali = new Validator('myParam', { fieldName: 'X' }); + expect(vali.config).to.eql({ fieldName: 'X' }); }); it('has access to name, type, params, config in getMessage provided by config', () => { @@ -87,7 +90,7 @@ describe('Validator', () => { return 'MyValidator'; } } - const vali = new MyValidator('myParam', { my: 'config', getMessage: configSpy }); + const vali = new MyValidator('myParam', { fieldName: 'X', getMessage: configSpy }); const { getMessage } = getProtectedMembers(vali); getMessage(); @@ -114,7 +117,7 @@ describe('Validator', () => { return ''; } } - const vali = new MyValidator('myParam', { my: 'config' }); + const vali = new MyValidator('myParam', { fieldName: 'X' }); const { getMessage } = getProtectedMembers(vali); getMessage(); @@ -137,12 +140,12 @@ describe('Validator', () => { }); it('fires "config-changed" event on config change', async () => { - const vali = new Validator('foo', { foo: 'bar' }); + const vali = new Validator('foo', { fieldName: 'X' }); const cb = sinon.spy(() => {}); if (vali.addEventListener) { vali.addEventListener('config-changed', cb); } - vali.config = { bar: 'foo' }; + vali.config = { fieldName: 'Y' }; expect(cb.callCount).to.equal(1); }); diff --git a/packages/form-integrations/test/form-validation-integrations.test.js b/packages/form-integrations/test/form-validation-integrations.test.js index 614523032..b9d2d6c27 100644 --- a/packages/form-integrations/test/form-validation-integrations.test.js +++ b/packages/form-integrations/test/form-validation-integrations.test.js @@ -46,7 +46,7 @@ describe('Form Validation Integrations', () => { await fixture(html` <${elTag} .validators=${[ - new Required(null, { getMessage: () => 'error' }), + new Required(null, { getMessage: async () => 'error' }), new WarnValidator(null, { getMessage: () => 'warning' }), new DefaultSuccess(), ]} diff --git a/packages/input-amount/src/LionInputAmount.js b/packages/input-amount/src/LionInputAmount.js index 93ebcff85..f7ae3274f 100644 --- a/packages/input-amount/src/LionInputAmount.js +++ b/packages/input-amount/src/LionInputAmount.js @@ -5,6 +5,11 @@ import { IsNumber } from '@lion/form-core'; import { formatAmount, formatCurrencyLabel } from './formatters.js'; import { parseAmount } from './parsers.js'; +/** + * @typedef {import('@lion/form-core/types/FormatMixinTypes').FormatOptions} FormatOptions + * @typedef {FormatOptions & {locale?:string;currency:string|undefined}} AmountFormatOptions + */ + /** * `LionInputAmount` is a class for an amount custom form element (``). * @@ -87,9 +92,10 @@ export class LionInputAmount extends LocalizeMixin(LionInput) { if (changedProperties.has('locale') && this.locale !== changedProperties.get('locale')) { if (this.locale) { - this.formatOptions.locale = this.locale; + /** @type {AmountFormatOptions} */ + (this.formatOptions).locale = this.locale; } else { - delete this.formatOptions.locale; + delete (/** @type {AmountFormatOptions} */ (this.formatOptions).locale); } this.__reformat(); } @@ -141,7 +147,8 @@ export class LionInputAmount extends LocalizeMixin(LionInput) { return; } - this.formatOptions.currency = currency || undefined; + /** @type {AmountFormatOptions} */ + (this.formatOptions).currency = currency || undefined; if (currency) { if (!this.__currencyDisplayNodeIsConnected) { this.appendChild(this.__currencyDisplayNode); diff --git a/packages/input-iban/src/validators.js b/packages/input-iban/src/validators.js index be9b09c73..5f45617d6 100644 --- a/packages/input-iban/src/validators.js +++ b/packages/input-iban/src/validators.js @@ -110,7 +110,7 @@ export class IsIBAN extends Validator { * @param {string} [data.type] * @param {Object.} [data.config] * @param {string} [data.name] - * @returns {Promise} + * @returns {Promise} */ static async getMessage(data) { await loadTranslations(); @@ -153,7 +153,7 @@ export class IsCountryIBAN extends IsIBAN { * @param {string} [data.type] * @param {Object.} [data.config] * @param {string} [data.name] - * @returns {Promise} + * @returns {Promise} */ static async getMessage(data) { await loadTranslations(); @@ -200,7 +200,7 @@ export class IsNotCountryIBAN extends IsIBAN { * @param {string} [data.type] * @param {Object.} [data.config] * @param {string} [data.name] - * @returns {Promise} + * @returns {Promise} */ static async getMessage(data) { await loadTranslations(); diff --git a/packages/input-tel/src/parsers.js b/packages/input-tel/src/parsers.js index bd5256bf8..48c873e4f 100644 --- a/packages/input-tel/src/parsers.js +++ b/packages/input-tel/src/parsers.js @@ -2,7 +2,7 @@ import { PhoneUtilManager } from './PhoneUtilManager.js'; /** * @typedef {import('../types').RegionCode} RegionCode - * @typedef {* & import('awesome-phonenumber').default} PhoneNumber + * @typedef {* & import('@lion/input-tel/lib/awesome-phonenumber-esm').default} PhoneNumber */ /** diff --git a/packages/validate-messages/src/loadDefaultFeedbackMessages.js b/packages/validate-messages/src/loadDefaultFeedbackMessages.js index 083b74ea5..ae9ca70d5 100644 --- a/packages/validate-messages/src/loadDefaultFeedbackMessages.js +++ b/packages/validate-messages/src/loadDefaultFeedbackMessages.js @@ -120,7 +120,7 @@ export function loadDefaultFeedbackMessages() { /** * @param {MessageData} data - * @returns {Promise} + * @returns {Promise} */ const getLocalizedMessage = async data => { await forMessagesToBeReady();