apostrophe-forms-regexp-text-field-widgets

Text fields that allow custom regular expression checks, for Apostrophe Forms

Usage no npm install needed!

<script type="module">
  import apostropheFormsRegexpTextFieldWidgets from 'https://cdn.skypack.dev/apostrophe-forms-regexp-text-field-widgets';
</script>

README

This module adds a new type of text field that allows the admin to specify their own regular expression. It is meant for use alongside the apostrophe-forms module.

Configuration

// in app.js
modules: {
  'apostrophe-forms': {
    formWidgets: {
      // other fields go here
      'apostrophe-forms-regexp-text-field': {}
    }
  },
  'apostrophe-forms-regexp-text-field-widgets'
}

Preventing DOS (Denial of Service) attacks

Since many regular expressions can run for hours on malicious input, which could completely block the site, this module uses the time-limited-regular-expressions module to limit the runtime to one-quarter second. This will not be an issue on reasonable input. If you do get a timeout message when testing your form, you should write a more efficient regular expression.