[Validator] Add filenameCharset and filenameCountUnit options to File constraint#58485
Conversation
OskarStark
left a comment
There was a problem hiding this comment.
Please add a testcase to avoid further regression
|
I'm 👎 here: the length in bytes is what matters. Eg a storage can have a 255-max string field counted in bytes, and this validator guards against longer filenames. Validating in code points makes it really hard to validate any predictable maxlength. Also, nothing tells this accepts only UTF-8 (it doesn't, bytes are bytes, no encoding expected here). |
|
Hello @nicolas-grekas For the context of the filenameMaxLength constraint option, from its name alone, it clearly suggests a validation on the string's length. let's take this example :
#[Assert\File( Result: I find this contradictory 😅. |
|
Hello @OskarStark ok, I'm waiting for the issue to be validated |
|
We could make this opt-in, eg with a countUnit and a charset option (names taken from the Length constraint) |
nicolas-grekas
left a comment
There was a problem hiding this comment.
LGTM, here are some minor last changes.
Please also rebase to target 7.3 since this is a new feature.
And move the changelog lines in the 7.3 section.
filenameCharset and filenameCountUnit options to File constraint
0e90fc5 to
d5dbcb5
Compare
aa6e31b to
5be38d9
Compare
5be38d9 to
c714aa5
Compare
| $payload, | ||
| $filenameCharset, | ||
| $filenameCountUnit, | ||
| $filenameCharsetMessage |
There was a problem hiding this comment.
| $filenameCharsetMessage | |
| $filenameCharsetMessage, |
…`File` constraint
|
Thank you @IssamRaouf. |
Uh oh!
There was an error while loading. Please reload this page.