Skip to content

CascadePublicMedia/views_argument_validator_regex

Repository files navigation

Views Contextual Filter Validator: Regular Expression

CONTENTS OF THIS FILE

  • Introduction
  • Requirements
  • Installation
  • Configuration
  • Use
  • Maintainers
  • License

INTRODUCTION

This module adds a Views contextual filter validator that can evaluate an argument based on user-supplied regular expression pattern.

REQUIREMENTS

No special requirements.

INSTALLATION

CONFIGURATION

The module has no menu or modifiable settings. There is no configuration.

USE

Add a Regular express (regex) validator to a View's contextual filter to use this module. E.g. --

  1. Create a new View with a page display.
  2. Add a contextual filter (Advanced -> Contextual Filters -> Add).
  3. From the "Add contextual filters" popup:
    • Select "Global" from the Category menu.
    • Enable the checkbox for the "Null" filter.
    • Click Add and configure contextual filters.
  4. Under When the filter value IS available or a default is provided, select Specify validation criteria and set the following options:
    • Validator: Regular expression (regex)
    • Regular expression: /^\d{4}$/
    • Action to take if filter value does not validate: Show Page not found
  5. Click Apply.
  6. Click Save for the full view.

This example ensure that the first contextual filter is exactly four digits. If the filters contains any non-digits or is not exactly four characters, the View page will give a "Page not found" error.

MAINTAINERS

Current maintainers:

This project is sponsored by:

LICENSE

All code in this repository is licensed GPLv2. A LICENSE file is not included in this repository per Drupal's module packing specifications.

See Licensing on Drupal.org.

About

Drupal 8 module adding a Views argument validator with regex support.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages