@@ -5106,6 +5106,191 @@ describe('Process Tests', function () {
51065106 processSync ( context ) ;
51075107 expect ( ( context . scope as ValidationScope ) . errors ) . to . have . length ( 1 ) ;
51085108 } ) ;
5109+
5110+ it ( 'Should not return the error for required component with logic where result var is used' , async function ( ) {
5111+ const form = {
5112+ components : [
5113+ {
5114+ label : 'Registration number required' ,
5115+ applyMaskOn : 'change' ,
5116+ tableView : true ,
5117+ case : 'uppercase' ,
5118+ validate : {
5119+ required : true ,
5120+ maxLength : 50 ,
5121+ } ,
5122+ validateWhenHidden : false ,
5123+ key : 'plateNumber2' ,
5124+ logic : [
5125+ {
5126+ name : 'keep letter and number' ,
5127+ trigger : {
5128+ type : 'javascript' ,
5129+ javascript : 'result=row[component.key];' ,
5130+ } ,
5131+ actions : [
5132+ {
5133+ name : 'set' ,
5134+ type : 'value' ,
5135+ value : "value=result.replace(/[^a-zA-Z0-9]/g, '');\n" ,
5136+ } ,
5137+ ] ,
5138+ } ,
5139+ ] ,
5140+ type : 'textfield' ,
5141+ input : true ,
5142+ keyModified : true ,
5143+ } ,
5144+ {
5145+ label : 'Submit' ,
5146+ showValidations : false ,
5147+ tableView : false ,
5148+ key : 'submit' ,
5149+ type : 'button' ,
5150+ input : true ,
5151+ } ,
5152+ ] ,
5153+ } ;
5154+ const submission = {
5155+ data : { plateNumber2 : 'TEST' , submit : true } ,
5156+ } ;
5157+ const context = {
5158+ form,
5159+ submission,
5160+ data : submission . data ,
5161+ components : form . components ,
5162+ processors : ProcessTargets . submission ,
5163+ scope : { } ,
5164+ } ;
5165+ processSync ( context as any ) ;
5166+ context . processors = ProcessTargets . evaluator ;
5167+ processSync ( context as any ) ;
5168+ assert . equal ( context . data . plateNumber2 , 'TEST' ) ;
5169+ assert . equal ( ( context . scope as any ) . errors . length , 0 ) ;
5170+ } ) ;
5171+
5172+ it ( 'Should return the value formatted by logic where result var is used' , async function ( ) {
5173+ const form = {
5174+ components : [
5175+ {
5176+ label : 'Registration number required' ,
5177+ applyMaskOn : 'change' ,
5178+ tableView : true ,
5179+ case : 'uppercase' ,
5180+ validate : {
5181+ required : true ,
5182+ maxLength : 50 ,
5183+ } ,
5184+ validateWhenHidden : false ,
5185+ key : 'plateNumber2' ,
5186+ logic : [
5187+ {
5188+ name : 'keep letter and number' ,
5189+ trigger : {
5190+ type : 'javascript' ,
5191+ javascript : 'result=row[component.key];' ,
5192+ } ,
5193+ actions : [
5194+ {
5195+ name : 'set' ,
5196+ type : 'value' ,
5197+ value : "value=result.replace(/[^a-zA-Z0-9]/g, '');\n" ,
5198+ } ,
5199+ ] ,
5200+ } ,
5201+ ] ,
5202+ type : 'textfield' ,
5203+ input : true ,
5204+ keyModified : true ,
5205+ } ,
5206+ {
5207+ label : 'Submit' ,
5208+ showValidations : false ,
5209+ tableView : false ,
5210+ key : 'submit' ,
5211+ type : 'button' ,
5212+ input : true ,
5213+ } ,
5214+ ] ,
5215+ } ;
5216+ const submission = {
5217+ data : { plateNumber2 : 'TEST 123 TEST' , submit : true } ,
5218+ } ;
5219+ const context = {
5220+ form,
5221+ submission,
5222+ data : submission . data ,
5223+ components : form . components ,
5224+ processors : ProcessTargets . submission ,
5225+ scope : { } ,
5226+ } ;
5227+ processSync ( context as any ) ;
5228+ context . processors = ProcessTargets . evaluator ;
5229+ processSync ( context as any ) ;
5230+ assert . equal ( context . data . plateNumber2 , 'TEST123TEST' ) ;
5231+ assert . equal ( ( context . scope as any ) . errors . length , 0 ) ;
5232+ } ) ;
5233+
5234+ it ( 'Should return the error for required component with logic where result var is used' , async function ( ) {
5235+ const form = {
5236+ components : [
5237+ {
5238+ label : 'Registration number required' ,
5239+ applyMaskOn : 'change' ,
5240+ tableView : true ,
5241+ case : 'uppercase' ,
5242+ validate : {
5243+ required : true ,
5244+ maxLength : 50 ,
5245+ } ,
5246+ validateWhenHidden : false ,
5247+ key : 'plateNumber2' ,
5248+ logic : [
5249+ {
5250+ name : 'keep letter and number' ,
5251+ trigger : {
5252+ type : 'javascript' ,
5253+ javascript : 'result=row[component.key];' ,
5254+ } ,
5255+ actions : [
5256+ {
5257+ name : 'set' ,
5258+ type : 'value' ,
5259+ value : "value=result.replace(/[^a-zA-Z0-9]/g, '');\n" ,
5260+ } ,
5261+ ] ,
5262+ } ,
5263+ ] ,
5264+ type : 'textfield' ,
5265+ input : true ,
5266+ keyModified : true ,
5267+ } ,
5268+ {
5269+ label : 'Submit' ,
5270+ showValidations : false ,
5271+ tableView : false ,
5272+ key : 'submit' ,
5273+ type : 'button' ,
5274+ input : true ,
5275+ } ,
5276+ ] ,
5277+ } ;
5278+ const submission = {
5279+ data : { plateNumber2 : '' , submit : true } ,
5280+ } ;
5281+ const context = {
5282+ form,
5283+ submission,
5284+ data : submission . data ,
5285+ components : form . components ,
5286+ processors : ProcessTargets . submission ,
5287+ scope : { } ,
5288+ } ;
5289+ processSync ( context as any ) ;
5290+ context . processors = ProcessTargets . evaluator ;
5291+ processSync ( context as any ) ;
5292+ assert . equal ( ( context . scope as any ) . errors . length , 1 ) ;
5293+ } ) ;
51095294 } ) ;
51105295 } ) ;
51115296
0 commit comments