@@ -98,6 +98,17 @@ inp().array()
9898 .optional () // Make field optional
9999```
100100
101+ ### Boolean Validation
102+ ``` ts
103+ inp ().boolean ()
104+ .true () // Must be true
105+ .false () // Must be false
106+ .equals (true ) // Must equal value
107+ .notEquals (false ) // Must not equal value
108+ .transform () // Transform strings/numbers to boolean
109+ .optional () // Make field optional
110+ ```
111+
101112### Object Validation
102113``` ts
103114inp ().object ({
@@ -144,15 +155,18 @@ inp().file()
144155export const validation: ValidationTypeBETA = {
145156 query: {
146157 page: inp ().number ().integer ().min (1 ).optional (),
147- limit: inp ().number ().integer ().range (1 , 100 )
158+ limit: inp ().number ().integer ().range (1 , 100 ),
159+ isActive: inp ().boolean ().transform () // Accepts "true", "1", true, etc.
148160 },
149161 body: inp ().object ({
150162 username: inp ().string ().min (3 ).max (255 ),
151163 email: inp ().string ().email (),
152164 age: inp ().number ().range (18 , 99 ),
165+ acceptTerms: inp ().boolean ().true (),
153166 profile: inp ().object ({
154167 bio: inp ().string ().max (1000 ).optional (),
155- interests: inp ().array ().every (inp ().string ()).max (10 )
168+ interests: inp ().array ().every (inp ().string ()).max (10 ),
169+ isPublic: inp ().boolean ().optional ()
156170 }),
157171 avatar: inp ().file ().maxSize (5 * 1024 * 1024 ).mimeType ([' image/jpeg' , ' image/png' ])
158172 }),
0 commit comments