Skip to content

Commit 1d905b9

Browse files
committed
Merge branch 'hotfix/1477'
Close zendframework#1477
2 parents 604d47b + 9d172c9 commit 1d905b9

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

docs/src/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ Programmer's Reference Guide of Zend Framework 2
294294
modules/zend.validator.validator-chains
295295
modules/zend.validator.writing-validators
296296
modules/zend.validator.messages
297+
modules/zend.validator.timezone
297298
modules/zend.version
298299
modules/zend.view.quick-start
299300
modules/zend.view.renderer.php-renderer
@@ -962,6 +963,7 @@ Zend\\Validator
962963
* :doc:`modules/zend.validator.sitemap`
963964
* :doc:`modules/zend.validator.step`
964965
* :doc:`modules/zend.validator.string-length`
966+
* :doc:`modules/zend.validator.timezone`
965967
* :doc:`modules/zend.validator.validator-chains`
966968
* :doc:`modules/zend.validator.writing-validators`
967969
* :doc:`modules/zend.validator.messages`

docs/src/modules/zend.validator.set.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Included Validators
3838
- :ref:`Sitemap <zend.validator.sitemap>`
3939
- :ref:`Step <zend.validator.step>`
4040
- :ref:`StringLength <zend.validator.stringlength>`
41+
- :ref:`Timezone <zend.validator.timezone>`
4142

4243
.. _zend.validator.set.deprecated-validators:
4344

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.. _zend.validator.timezone:
2+
3+
Timezone Validator
4+
==============
5+
6+
``Zend\Validator\Timezone`` allows validating if an input string
7+
represents a timezone.
8+
9+
Supported validation types for Zend\\Validator\\Timezone
10+
--------------------------------------------------------
11+
12+
The ``Zend\Validator\Timezone`` validator is capable of validating the
13+
abbreviation (e.g. "ewt") as well as the location string (e.g.
14+
"America/Los\_Angeles"). These options are stored in the validator as
15+
``LOCATION``, ``ABBREVIATION``, and ``ALL`` class constants.
16+
17+
Example Usage
18+
-------------
19+
20+
The default validation type will check again abbreviations as well as
21+
the location string.
22+
23+
.. code:: php
24+
25+
$validator = new Zend\Validator\Timezone();
26+
27+
$validator->isValid('America/Los_Angeles'); // returns true
28+
$validator->isValid('ewt'); // returns true
29+
$validator->isValid('Foobar'); // returns false
30+
31+
To validate against only the location string you can set the type:
32+
33+
.. code:: php
34+
35+
$validator = new Zend\Validator\Timezone();
36+
$validator->setType(Zend\Validator\Timezone::LOCATION);
37+
38+
$validator->isValid('America/Los_Angeles'); // returns true
39+
$validator->isValid('ewt'); // returns false
40+
$validator->isValid('Foobar'); // returns false
41+

0 commit comments

Comments
 (0)