Textpattern PHP Cross Reference Content Management Systems

Source: /textpattern/vendors/Textpattern/Validator/BlankConstraint.php - 59 lines - 1454 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /*
   4   * Textpattern Content Management System
   5   * https://textpattern.com/
   6   *
   7   * Copyright (C) 2020 The Textpattern Development Team
   8   *
   9   * This file is part of Textpattern.
  10   *
  11   * Textpattern is free software; you can redistribute it and/or
  12   * modify it under the terms of the GNU General Public License
  13   * as published by the Free Software Foundation, version 2.
  14   *
  15   * Textpattern is distributed in the hope that it will be useful,
  16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18   * GNU General Public License for more details.
  19   *
  20   * You should have received a copy of the GNU General Public License
  21   * along with Textpattern. If not, see <https://www.gnu.org/licenses/>.
  22   */
  23  
  24  namespace Textpattern\Validator;
  25  
  26  /**
  27   * Validates that a value is blank, defined as equal to a blank string or equal
  28   * to null.
  29   *
  30   * @since   4.6.0
  31   * @package Validator
  32   */
  33  
  34  class BlankConstraint extends Constraint
  35  {
  36      /**
  37       * Constructor.
  38       *
  39       * @param mixed $value
  40       * @param array $options
  41       */
  42  
  43      public function __construct($value, $options = array())
  44      {
  45          $options = lAtts(array('message' => 'should_be_blank'), $options, false);
  46          parent::__construct($value, $options);
  47      }
  48  
  49      /**
  50       * Validates.
  51       *
  52       * @return bool
  53       */
  54  
  55      public function validate()
  56      {
  57          return $this->value === '' || $this->value === null;
  58      }
  59  }

title

Description

title

Description

title

Description

title

title

Body