script-server icon indicating copy to clipboard operation
script-server copied to clipboard

[WiP] Textfield to support RegExp validation

Open drehelis opened this issue 4 years ago • 0 comments

I was in a need for special form of text field validation done on the frontend. This PR tries to solve this by adding regular-expression validation capabilities.

Couple of caveats -

  • Escaping characters such as \ when editing JSON config manually is required.
  • ~~Can't get the Admin UI properly generate regex object. Hence, WiP :-)~~
  • Add Tests

Parameter config should look like:

{
  "name": "RegExp textfield",
  "max_length": "12",
  "regex": {
    "pattern": "^([a-z0-9_\\.-]+)@([\\da-z\\.-]+)\\.([a-z\\.]{2,6})$",
    "description": "Email address only"
  }
}

Small demo:

https://user-images.githubusercontent.com/11921235/121894690-1afb6100-cd28-11eb-8b36-a59df6a3c53f.mov

drehelis avatar Jun 14 '21 12:06 drehelis