NumericArgumentValidator.php

Same filename and directory in other branches
  1. 8.9.x core/modules/views/src/Plugin/views/argument_validator/NumericArgumentValidator.php
  2. 10 core/modules/views/src/Plugin/views/argument_validator/NumericArgumentValidator.php
  3. 11.x core/modules/views/src/Plugin/views/argument_validator/NumericArgumentValidator.php

Namespace

Drupal\views\Plugin\views\argument_validator

File

core/modules/views/src/Plugin/views/argument_validator/NumericArgumentValidator.php

View source
<?php

namespace Drupal\views\Plugin\views\argument_validator;

use Drupal\Core\Plugin\Context\ContextDefinition;

/**
 * Validate whether an argument is numeric or not.
 *
 * @ingroup views_argument_validate_plugins
 *
 * @ViewsArgumentValidator(
 *   id = "numeric",
 *   title = @Translation("Numeric")
 * )
 */
class NumericArgumentValidator extends ArgumentValidatorPluginBase {
    public function validateArgument($argument) {
        return is_numeric($argument);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getContextDefinition() {
        return new ContextDefinition('integer', $this->argument
            ->adminLabel(), FALSE);
    }

}

Classes

Title Deprecated Summary
NumericArgumentValidator Validate whether an argument is numeric or not.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.