Closed Alyxsqrd closed 3 months ago
@Alyxsqrd Hi,
Thanks for the suggestion, unfortunately, any options that are unknown to the Json Schema specification are deemed out of scope (which would include the trim: true
option). Although it might be possible to implement trim functionality using Transform types.
Just keep in mind, it's generally better to ensure senders of data transmit 'pre-trimmed' / 'correct' data rather than having the validator side fix incorrect data (where it's generally best practice to ensure the receiver is strict). This can help mitigate ambiguities determining the exact inputs a receiver can receive.
Will close off this issue for now. Cheers S
Hello, I noticed that the
maxLength
andminLength
options inStringOptions
don't check against trimmed strings. This seems like a problem if validating against something likeminLength: 10
wheretest
would fail buttest
with empty spaces at the start/end would succeed. Iftrim: true
, typebox should return the trimmed string as well.