sinclairzx81 / typebox

Json Schema Type Builder with Static Type Resolution for TypeScript
Other
4.79k stars 153 forks source link

Revision 0.32.13 #744

Closed sinclairzx81 closed 7 months ago

sinclairzx81 commented 7 months ago

This PR adds specialized string length constraints for the RegExp type. These constraints were missed on 0.32.0.

Prior to this revision, users would need to intersect a RegExp with a String containing the string length constraints.

const T = Type.Intersect([
   Type.String({ minLength: 3, maxLength: 10 }),
   Type.RegExp(/(.*)/)
])

This PR adds them directly to RegExp

const T = Type.RegExp(/(.*)/, {
  minLength: 3, maxLength: 10
})

RegExp range constraint errors will generate String range errors on validation failure.