Closed arrilot closed 1 year ago
Should it allow \Stringable
as well?
I don't have a strong opinion on that matter but I guess no:
StringValue
rule adhere Stringable
then?is_string
for Type('string')
aswell https://github.com/symfony/validator/blob/6.2/Constraints/TypeValidator.php#L33Should it allow
\Stringable
as well?
Maybe add option allowStringable
with false
as default?
@vjik And in the Length
too?
@vjik And in the
Length
too?
I would add to Length
when there is a need for it.
As for StringValue::$allowStringable
- suggest to do it in a separate PR, maybe discuss more.
This very basic rule is pretty much required when we use validator in a context like https://github.com/yiisoft/request-model Imagine we want to decode JSON body and check that particular JSON fields are strings
There are
BoolValue
,TrueValue
andIntegerValue
rules, butStringValue
seems to be missing. There is also a workaround with an emptyLength
rule but using it for validation variable type is kinda strange.