Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

param_verify

1 sites Security covered
View on drupal.org

This module does nothing on its own, it's for developers only. It provides the glue from the param_verify package (on packagist) to Drupal by supplying a service to the factory class. It does nothing else.

If loaded using composer it will fetch the adaddinsane/param_verify package, and its dependencies.

How it works

Adapted from the README file of adaddinsane/param_verify.

This package can verify (type check) a set of array values, which are most likely parameters in a call, to ensure they are of the right type, and in some cases within range. It covers most PHP types.

Sometimes you cannot specify in a list of arguments in a function/method perhaps because it's too long, or because they might vary too much between derived class types. Or possibly the data is coming from an external source, such as an API call, and you want to make sure all the required values exist, and all supplied values are the right type.

This class is configured with an array which provides a list of which values are required and their types. Optional values can also be included in which case they are only checked if they are present (no error is generated if they are missing).

When a verification is performed a list of errors will be returned, if it's empty then everything was fine.

Structure

---------
The settings array looks like this:

[
  'name' => [
    'required' => true,
    'type' => 'string',
    'data' => '',
    'range' => []
  ]
]

The 'name' is the key value in the array being tested (the name of the property).

Only the 'type' key is mandatory, and must be one of the acceptable values; the 'required' key is assumed false if missing; some types require an additional data string, for a 'regex' type it's the regular expression, for the 'class' type it's the fully qualified class name, and so on.

The 'range' key applies to string, int and float, and allows length and range restrictions to be inserted.

Types

The complete list of types:

  • any matches anything
  • null matches only a null value (for completeness, you never know)
  • class matches a specific class or interface (FQN in 'data')
  • object matches any object
  • array matches any array, arrays can contain their own sub-definitions.
  • int matches an integer value (and can have a range)
  • bool only matches true or false
  • int_bool matches true, false, 0 or 1
  • float matches a float value (and can have a range)
  • string matches any string (and can have a range)
  • string_list matches a string against a fixed list of strings (in 'data' separated by '|'). This is like an old style "enum". This type is also used to verify the types of the settings/configuration items.
  • regex tests a string with a regular expression (in 'data')
  • callable only matches a callable
  • resource only matches a resource
  • url matches a string which is also a valid URL
  • email matches a string which is also a valid email address
  • enum** only matches a PHP8.1 enum (FQN in 'data')

For further information see the package README file.

Requirements

Drupal 8 or 9 at present. PHP 7.4 or better, PHP 8.1 allows the use of the "enum" verifier.

Installation

Install with composer: composer require drupal/param_verify:^1.4

Support

Do you like to read Science Fiction, Fantasy, Steampunk or Crime Fiction? You might find something you like here most books also available through Kindle Unlimited.

Activity

Total releases
2
First release
Aug 2025
Latest release
7 months ago
Release cadence
0 days
Stability
0% stable

Releases

Version Type Release date
2.0.0-beta1 Pre-release Aug 27, 2025
2.0.x-dev Dev Aug 27, 2025