You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Damn, trim and minLength / maxLength are also broken in combination.
Trimming should be done first and min/max length checking should be done on the trimmed string, not on the untrimmed string:
const s = st.string({trim: true, minLength: 1, maxLength: 3})
s(' ') === '' // true, should raise an error instead because '' is not long enough
s('abc ') // raises an error but should not because 'abc' is still within maxLength
See the following test cases:
(1) Without trim option - optional fields are correctly not returned as they are not defined in the input.
(2) With trim option - all optional fields incorrectly returned with
undefined
values.Many libraries will treat the two objects differently which can cause downstream issues.
The text was updated successfully, but these errors were encountered: