diff --git a/src/lib/DurationInput.svelte b/src/lib/DurationInput.svelte index 642caf1..6533faf 100644 --- a/src/lib/DurationInput.svelte +++ b/src/lib/DurationInput.svelte @@ -80,7 +80,7 @@ /** Whether the input is required */ required?: boolean; /** Message to show when the input is invalid */ - invalidMessage?: string; + invalidMessage?: string | null; /** Whether to use compact styling */ compact?: boolean; /** Additional classes are applied to the root container (div element) */ @@ -96,7 +96,7 @@ value = $bindable(null), formattedValue = $bindable(''), required = false, - invalidMessage = 'Please enter a duration', + invalidMessage = null, compact, class: classValue, onchange @@ -280,6 +280,7 @@ placeholder={opts.placeholder} validate={{ pattern: opts.pattern }} use={(n) => liveValidator(n, keydownValidatorOpts)} + forceInvalid={!valid} onkeydown={opts.onkeydown} oninput={opts.oninput} onblur={opts.onblur} @@ -296,4 +297,12 @@ {/if} {/each} + + {#if !valid && invalidMessage} +