Skip to content

Commit 7768b97

Browse files
committed
implement setCustomValidity
1 parent c0aa7d9 commit 7768b97

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/uui-base/lib/mixins/FormControlMixin.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,20 @@ export const FormControlMixin = <T extends Constructor<LitElement>>(
209209
this._formCtrlElements.push(element);
210210
}
211211

212+
/**
213+
* @method setCustomValidity
214+
* @description Set custom validity state, set to empty string to remove the custom message.
215+
* @param message {string} - The message to be shown
216+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity|HTMLObjectElement:setCustomValidity}
217+
*/
218+
protected setCustomValidity(message: string) {
219+
this._internals.setValidity(
220+
'customError',
221+
message,
222+
this.getFormElement()
223+
);
224+
}
225+
212226
private _runValidators() {
213227
this._validityState = {};
214228

0 commit comments

Comments
 (0)