How to set client-side validation messages in custom property editor?
m
So i'm messing around with the new Backoffice UI, and have created a property editor, and would like to add client-side validation on the fields, to help the editors. So I have the the code below, and validation works, I get a validation message, but I'm guessing it's the standard message from the browser. So my questions are: 1. Should I even be using UmbValidationContext? 2. If so, is there a method to setting the validation message?
Copy code
#validate = () => {
    this.#validation.validate().then(() => {
        console.log('Valid');
    }, () => {
        console.log('Invalid');
    });
}

#onMaxWidthInput(e: InputEvent) {
    let target = e.target as HTMLInputElement;
    this._maxWidth = target.value;

    this.#validate();
}

<uui-input
    label="Max Width"
    class="element" 
    pattern="^[1-9][0-9]*$" 
    ${umbBindToValidation(this)}
    .value=${this._maxWidth || ""}
    @input=${this.#onMaxWidthInput}>
</uui-input>
17 Views