@@ -1164,7 +1164,6 @@ describe('validateInsertRequest', () => {
11641164 } ) ;
11651165
11661166 // Test valid cases
1167- // Test valid cases
11681167test ( 'should accept valid insert request' , ( ) => {
11691168 const request = {
11701169 _table : 'users' , // Changed from table to _table
@@ -1177,6 +1176,52 @@ test('should accept valid insert request', () => {
11771176 expect ( ( ) => validateInsertRequest ( request ) ) . not . toThrow ( ) ;
11781177} ) ;
11791178
1179+ test ( 'should accept insert request with null field values' , ( ) => {
1180+ const request = {
1181+ _table : 'sensitive_data_table' ,
1182+ table : 'sensitive_data_table' ,
1183+ data : [
1184+ { card_number : null }
1185+ ]
1186+ } ;
1187+ expect ( ( ) => validateInsertRequest ( request ) ) . not . toThrow ( ) ;
1188+ } ) ;
1189+
1190+ test ( 'should accept insert request with empty string field values' , ( ) => {
1191+ const request = {
1192+ _table : 'sensitive_data_table' ,
1193+ table : 'sensitive_data_table' ,
1194+ data : [
1195+ { card_number : '' }
1196+ ]
1197+ } ;
1198+ expect ( ( ) => validateInsertRequest ( request ) ) . not . toThrow ( ) ;
1199+ } ) ;
1200+
1201+ test ( 'should accept insert request with mixed null, empty string and valid field values' , ( ) => {
1202+ const request = {
1203+ _table : 'sensitive_data_table' ,
1204+ table : 'sensitive_data_table' ,
1205+ data : [
1206+ { card_number : '4111111111111112' , cvv : null , expiry : '' }
1207+ ]
1208+ } ;
1209+ expect ( ( ) => validateInsertRequest ( request ) ) . not . toThrow ( ) ;
1210+ } ) ;
1211+
1212+ test ( 'should accept insert request with multiple records containing null and empty values' , ( ) => {
1213+ const request = {
1214+ _table : 'sensitive_data_table' ,
1215+ table : 'sensitive_data_table' ,
1216+ data : [
1217+ { card_number : '4111111111111112' } ,
1218+ { card_number : null } ,
1219+ { card_number : '' }
1220+ ]
1221+ } ;
1222+ expect ( ( ) => validateInsertRequest ( request ) ) . not . toThrow ( ) ;
1223+ } ) ;
1224+
11801225// Also update other test cases that check table property
11811226test ( 'should throw error when table is missing' , ( ) => {
11821227 const request = {
@@ -1421,17 +1466,56 @@ describe('validateUpdateRequest - validateUpdateInput', () => {
14211466 . toThrow ( SKYFLOW_ERROR_CODE . INVALID_TYPE_OF_UPDATE_DATA ) ;
14221467 } ) ;
14231468
1424- // Test validateUpdateInput with null values
1425- test ( 'should throw error when data contains null values' , ( ) => {
1469+ // Test validateUpdateInput with null values — should be accepted
1470+ test ( 'should accept update data with null field values' , ( ) => {
14261471 const request = {
14271472 ...validTable ,
14281473 data : {
1429- skyflow_id : 'valid-id' ,
1474+ skyflowId : 'valid-id' ,
14301475 field : null
14311476 }
14321477 } ;
1433- expect ( ( ) => validateUpdateRequest ( request ) )
1434- . toThrow ( SKYFLOW_ERROR_CODE . INVALID_RECORD_IN_UPDATE ) ;
1478+ expect ( ( ) => validateUpdateRequest ( request ) ) . not . toThrow ( ) ;
1479+ } ) ;
1480+
1481+ // Test validateUpdateInput with empty string field values — should be accepted
1482+ test ( 'should accept update data with empty string field values' , ( ) => {
1483+ const request = {
1484+ ...validTable ,
1485+ data : {
1486+ skyflowId : 'valid-id' ,
1487+ field : ''
1488+ }
1489+ } ;
1490+ expect ( ( ) => validateUpdateRequest ( request ) ) . not . toThrow ( ) ;
1491+ } ) ;
1492+
1493+ // Test validateUpdateInput with mixed null, empty string and valid values
1494+ test ( 'should accept update data with mixed null, empty string and valid field values' , ( ) => {
1495+ const request = {
1496+ ...validTable ,
1497+ data : {
1498+ skyflowId : 'valid-id' ,
1499+ card_number : null ,
1500+ name : '' ,
1501+ ssn : '123-45-6789'
1502+ }
1503+ } ;
1504+ expect ( ( ) => validateUpdateRequest ( request ) ) . not . toThrow ( ) ;
1505+ } ) ;
1506+
1507+ // Test validateUpdateInput with numeric and boolean field values
1508+ test ( 'should accept update data with numeric and boolean field values' , ( ) => {
1509+ const request = {
1510+ ...validTable ,
1511+ data : {
1512+ skyflowId : 'valid-id' ,
1513+ age : 0 ,
1514+ active : false ,
1515+ score : 99.5
1516+ }
1517+ } ;
1518+ expect ( ( ) => validateUpdateRequest ( request ) ) . not . toThrow ( ) ;
14351519 } ) ;
14361520
14371521 // Test valid update data with multiple fields
0 commit comments