File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
packages/uui-base/lib/mixins Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export declare abstract class FormControlMixinInterface extends LitElement {
16
16
formResetCallback ( ) : void ;
17
17
checkValidity ( ) : boolean ;
18
18
get validationMessage ( ) : string ;
19
+ get validity ( ) : ValidityState ;
19
20
public setCustomValidity ( error : string ) : void ;
20
21
protected _value : FormDataEntryValue | FormData ;
21
22
protected _internals : any ;
@@ -302,6 +303,9 @@ export const FormControlMixin = <T extends Constructor<LitElement>>(
302
303
303
304
const hasError = Object . values ( this . _validityState ) . includes ( true ) ;
304
305
306
+ // https://developer.mozilla.org/en-US/docs/Web/API/ValidityState#valid
307
+ this . _validityState . valid = ! hasError ;
308
+
305
309
if ( hasError ) {
306
310
this . dispatchEvent (
307
311
new UUIFormControlEvent ( UUIFormControlEvent . INVALID )
@@ -347,6 +351,11 @@ export const FormControlMixin = <T extends Constructor<LitElement>>(
347
351
return this . _internals ?. checkValidity ( ) ;
348
352
}
349
353
354
+ // https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
355
+ public get validity ( ) : ValidityState {
356
+ return this . _validityState ;
357
+ }
358
+
350
359
get validationMessage ( ) {
351
360
return this . _internals ?. validationMessage ;
352
361
}
You can’t perform that action at this time.
0 commit comments