From 14ae5c67ea2367fa5b51878ed87e635c5e9c79c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Bru=CC=88ckner?= Date: Thu, 13 Dec 2018 22:15:56 +0100 Subject: [PATCH 1/3] Removes private property from supported options --- doc/book/validators/string-length.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/book/validators/string-length.md b/doc/book/validators/string-length.md index d155d4b14..c27527721 100644 --- a/doc/book/validators/string-length.md +++ b/doc/book/validators/string-length.md @@ -15,7 +15,6 @@ The following options are supported for `Zend\Validator\StringLength`: - `encoding`: Sets the `ICONV` encoding to use with the string. - `min`: Sets the minimum allowed length for a string. - `max`: Sets the maximum allowed length for a string. -- `length`: Holds the actual length of the string. ## Default behaviour From f32f725dc9061dc12dca147bc1d087cd27467787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Bru=CC=88ckner?= Date: Thu, 13 Dec 2018 22:16:33 +0100 Subject: [PATCH 2/3] Adds code example for limiting to a strict length --- doc/book/validators/string-length.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/book/validators/string-length.md b/doc/book/validators/string-length.md index c27527721..12fba9b07 100644 --- a/doc/book/validators/string-length.md +++ b/doc/book/validators/string-length.md @@ -84,6 +84,19 @@ $validator->isValid("Test"); // returns true $validator->isValid("Testing"); // returns true ``` +## Limiting to a strict length + +If you need a strict length, then set the `min` and `max` properties to the same +value: + +```php +$validator = new Zend\Validator\StringLength(['min' => 4, 'max' => 4]); + +$validator->isValid('Tes'); // returns false +$validator->isValid('Test'); // returns true +$validator->isValid('Testi'); // returns false +``` + > ### Setting a maximum lower than the minimum > > When you try to set a lower maximum value than the specified minimum value, or From 9bd8215f0716d781cee97241aec4d80f5bc82986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Bru=CC=88ckner?= Date: Thu, 13 Dec 2018 22:18:04 +0100 Subject: [PATCH 3/3] Fixes headlines in StringLength validator documentation --- doc/book/validators/string-length.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/book/validators/string-length.md b/doc/book/validators/string-length.md index 12fba9b07..831ab954b 100644 --- a/doc/book/validators/string-length.md +++ b/doc/book/validators/string-length.md @@ -3,7 +3,7 @@ This validator allows you to validate if a given string is between a defined length. -> Supports only string validation +> ### Supports only string validation > > `Zend\Validator\StringLength` supports only the validation of strings. > Integers, floats, dates or objects can not be validated with this validator. @@ -97,7 +97,7 @@ $validator->isValid('Test'); // returns true $validator->isValid('Testi'); // returns false ``` -> ### Setting a maximum lower than the minimum +> ### Setting a maximum lower than the minimum > > When you try to set a lower maximum value than the specified minimum value, or > a higher minimum value as the actual maximum value, the validator will raise