How to add validation to a custom order line property in Umbraco Commerce 15?

Hello Umbracian,

I have added a custom order line property in Umbraco Commerce 15 using the following snippet:

“extensions”: [
{
“type”: “ucOrderLineProperty”,
“alias”: “Uc.OrderLineProperty.Sequence”,
“name”: “Sequence”,
“weight”: 400,
“meta”: {
“propertyAlias”: “sequence”,
“readOnly”: true,
“showInOrderLineSummary”: true,
“summaryStyle”: “table”,
“editorUiAlias”: “Umb.PropertyEditorUi.TextBox”,
“labelUiAlias”: “Umb.PropertyEditorUi.Label”
}
}]

This works fine, but now I’d like to add regex validation.

What is the recommended way to add validation rules to custom order line properties in Commerce 15? Should this be done via editorConfig ?

Any guidance or working examples would be much appreciated!

Thanks in Advance

Hi @ashachaudharygd

Could you please try something like below :

"extensions": [
  {
    "type": "ucOrderLineProperty",
    "alias": "Uc.OrderLineProperty.Sequence",
    "name": "Sequence",
    "weight": 400,
    "meta": {
      "propertyAlias": "sequence",
      "readOnly": false,
      "showInOrderLineSummary": true,
      "summaryStyle": "table",
      "editorUiAlias": "Umb.PropertyEditorUi.TextBox",
      "labelUiAlias": "Umb.PropertyEditorUi.Label",
      "editorConfig": {
        "regex": "^[0-9]{1,5}$",
        "regexMessage": "Please enter a numeric sequence (1–5 digits)."
      }
    }
  }
]

Thank you @deepakaggrawal for looking into this.

I had actually tried that earlier, but unfortunately it didn’t work for me.