@@ -144,7 +144,7 @@ const defaults = {
144144/**
145145 * Expected constraints for libraries with introspection
146146 */
147- function fullConstraints ( library : 'zod4' | 'unknown' ) {
147+ function fullConstraints ( library : 'zod4' | 'arktype' | ' unknown') {
148148 const defaultConstraints = {
149149 email : {
150150 required : true
@@ -176,6 +176,14 @@ function fullConstraints(library: 'zod4' | 'unknown') {
176176 max : Number . MAX_SAFE_INTEGER
177177 }
178178 } ;
179+ case 'arktype' :
180+ return {
181+ ...defaultConstraints ,
182+ email : {
183+ ...defaultConstraints . email ,
184+ pattern : '^[\\w%+.-]+@[\\d.A-Za-z-]+\\.[A-Za-z]{2,}$'
185+ }
186+ } ;
179187 default :
180188 return defaultConstraints ;
181189 }
@@ -368,18 +376,39 @@ describe('Schemasafe', () => {
368376/////////////////////////////////////////////////////////////////////
369377
370378describe ( 'Arktype' , ( ) => {
379+ it ( 'should handle defaults, even when upgraded to full adapter' , async ( ) => {
380+ const schema = type ( {
381+ name : 'string > 2'
382+ } ) ;
383+ const adapter = arktype ( schema , { defaults : { name : 'Test' } } ) ;
384+ const form = await superValidate ( { } , adapter ) ;
385+ expect ( form . data ) . toEqual ( { name : 'Test' } ) ;
386+ } ) ;
387+
388+ it ( 'should handle bigint' , async ( ) => {
389+ const schema = type ( {
390+ id : 'bigint'
391+ } ) ;
392+ const adapter = arktype ( schema ) ;
393+ const formData = new FormData ( ) ;
394+ formData . set ( 'id' , '123456789123456789' ) ;
395+
396+ const form = await superValidate ( formData , adapter ) ;
397+ expect ( form . data ) . toEqual ( { id : 123456789123456789n } ) ;
398+ } ) ;
399+
371400 const schema = type ( {
372- name : 'string' ,
401+ name : 'string = "Unknown" ' ,
373402 email : 'string.email' ,
374403 tags : '(string>=2)[]>=3' ,
375404 score : 'number.integer>=0' ,
376- 'date?' : 'Date' ,
405+ 'date?' : 'Date | undefined ' ,
377406 'nospace?' : nospacePattern ,
378407 extra : 'string|null'
379408 } ) ;
380409
381- const adapter = arktype ( schema , { defaults } ) ;
382- schemaTest ( adapter , [ 'email' , 'date' , ' nospace', 'tags' ] , 'simple ') ;
410+ const adapter = arktype ( schema ) ;
411+ schemaTest ( adapter , [ 'email' , 'nospace' , 'tags' ] , undefined , undefined , 'arktype ') ;
383412} ) ;
384413
385414/////////////////////////////////////////////////////////////////////
@@ -1302,7 +1331,7 @@ function schemaTest(
13021331 errors : ErrorFields = [ 'email' , 'nospace' , 'tags' , 'tags[1]' ] ,
13031332 adapterType : 'full' | 'simple' = 'full' ,
13041333 dateFormat : 'Date' | 'string' | 'stringToDate' = 'Date' ,
1305- library : 'unknown' | 'zod4' = 'unknown'
1334+ library : 'unknown' | 'zod4' | 'arktype' = 'unknown'
13061335) {
13071336 const validD = { ...validData , date : dateFormat !== 'Date' ? '2024-01-01' : validData . date } ;
13081337
@@ -1312,8 +1341,6 @@ function schemaTest(
13121341
13131342 // eslint-disable-next-line @typescript-eslint/no-explicit-any
13141343 function expectErrors ( errors : ErrorFields , errorMessages : Record < string , any > ) {
1315- // console.log('🚀 ~ expectErrors ~ errorMessages:', errorMessages);
1316-
13171344 if ( errors . includes ( 'nospace' ) )
13181345 expect ( errorMessages . nospace , missingError ( 'nospace' ) ) . toBeTruthy ( ) ;
13191346 if ( errors . includes ( 'email' ) ) expect ( errorMessages . email , missingError ( 'email' ) ) . toBeTruthy ( ) ;
0 commit comments