File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -294,6 +294,7 @@ Programmer's Reference Guide of Zend Framework 2
294
294
modules/zend.validator.validator-chains
295
295
modules/zend.validator.writing-validators
296
296
modules/zend.validator.messages
297
+ modules/zend.validator.timezone
297
298
modules/zend.version
298
299
modules/zend.view.quick-start
299
300
modules/zend.view.renderer.php-renderer
@@ -962,6 +963,7 @@ Zend\\Validator
962
963
* :doc: `modules/zend.validator.sitemap `
963
964
* :doc: `modules/zend.validator.step `
964
965
* :doc: `modules/zend.validator.string-length `
966
+ * :doc: `modules/zend.validator.timezone `
965
967
* :doc: `modules/zend.validator.validator-chains `
966
968
* :doc: `modules/zend.validator.writing-validators `
967
969
* :doc: `modules/zend.validator.messages `
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ Included Validators
38
38
- :ref: `Sitemap <zend.validator.sitemap >`
39
39
- :ref: `Step <zend.validator.step >`
40
40
- :ref: `StringLength <zend.validator.stringlength >`
41
+ - :ref: `Timezone <zend.validator.timezone >`
41
42
42
43
.. _zend.validator.set.deprecated-validators :
43
44
Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments