Package Home

Zend Framework 2 Documentation (Manual)

PHK Home

File: /modules/zend.validator.step.html

Size:12263
Storage flags:no_autoload,compress/gzip (26%)

Step Validator — Zend Framework 2 2.4.2 documentation

Step Validator

Zend\Validator\Step allows you to validate if a given value is a valid step value. This validator requires the value to be a numeric value (either string, int or float).

Supported options for Zend\Validator\Step

The following options are supported for Zend\Validator\Step:

  • baseValue: This is the base value from which the step should be computed. This option defaults to 0
  • step: This is the step value. This option defaults to 1

Basic usage

A basic example is the following one:

1
2
3
4
5
6
7
$validator = new Zend\Validator\Step();

if ($validator->isValid(1)) {
    // value is a valid step value
} else {
    // false
}

Using floating-point values

This validator also supports floating-point base value and step value. Here is a basic example of this feature:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
$validator = new Zend\Validator\Step(
    array(
        'baseValue' => 1.1,
        'step'      => 2.2,
    )
);

echo $validator->isValid(1.1); // prints true
echo $validator->isValid(3.3); // prints true
echo $validator->isValid(3.35); // prints false
echo $validator->isValid(2.2); // prints false

Table Of Contents

Previous topic

Sitemap Validators

Next topic

Validator Chains

This Page

Note: You need to stay logged into your GitHub account to contribute to the documentation.

Edit this document

Edit this document

The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.

  1. Login with your GitHub account.
  2. Go to Step Validator on GitHub.
  3. Edit file contents using GitHub's text editor in your web browser
  4. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  5. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  6. Your changes are now queued for review under project's Pull requests tab on GitHub.

For more information about the PHK package format: http://phk.tekwire.net