Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

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;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\views\Attribute\ViewsArgumentValidator;

/**
 * Validate whether an argument is numeric or not.
 *
 * @ingroup views_argument_validate_plugins
 */
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.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal