Closed allen05ren closed 5 years ago
Probably not: if they are unused, they should instead be dropped.
@allen05ren
getLength() and setLength() visibility shold be public ?
Not needed, because the description of validator is:
This validator allows you to validate if a given string is between a defined length.
If you need a strict length, then set the min
and max
values to the same value:
$validator = new \Zend\Validator\StringLength(
[
'min' => 3,
'max' => 3,
]
);
var_dump($validator->isValid('foo')); // true
var_dump($validator->isValid('fo')); // false
var_dump($validator->isValid('foobar')); // false
@Ocramius
The methods are used in the method isValid
:
But the documentation is misleading here:
https://docs.zendframework.com/zend-validator/validators/string-length/#supported-options
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.
"Holds" is correct, but it can not be set or is public.
@froschdesign Yes, i see. You are right, it can not be set or is public.
getLength()
andsetLength()
visibility shold be public ?https://github.com/zendframework/zend-validator/blob/87e743d11d49a157011a49a962c25e7a11adc7c5/src/StringLength.php#L182-L202