Package Home

Zend Framework 2 Documentation (Manual)

PHK Home

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

Size:10622
Storage flags:no_autoload,compress/gzip (30%)

Digits Validator — Zend Framework 2 2.4.2 documentation

Digits Validator

Zend\Validator\Digits validates if a given value contains only digits.

Supported options for Zend\Validator\Digits

There are no additional options for Zend\Validator\Digits:

Validating digits

To validate if a given value contains only digits and no other characters, simply call the validator like shown in this example:

1
2
3
4
5
$validator = new Zend\Validator\Digits();

$validator->isValid("1234567890"); // returns true
$validator->isValid(1234);         // returns true
$validator->isValid('1a234');      // returns false

Note

Validating numbers

When you want to validate numbers or numeric values, be aware that this validator only validates digits. This means that any other sign like a thousand separator or a comma will not pass this validator. In this case you should use Zend\I18n\Validator\Int or Zend\I18n\Validator\Float.

Table Of Contents

Previous topic

Db\RecordExists and Db\NoRecordExists Validators

Next topic

File Validation Classes

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 Digits 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