Conditional required data tables

Hello - I have 2 data tables that are conditional. One data table is required if the ticket is "aging". The other data table is required if the ticket is "lockbox". Could I get some help with the code? I am getting an unmatched { error on the first row (fd.rendered (function() {
and an expected identifier error at the bottom of the function.

fd.rendered(function() {
    fd.field('InquiryType').$on('change',function(value){   
    // Validate required column fields are not empty
       if(value == "LockBox") {
    fd.control('LockBoxClaimInquiries').addValidator({
        name: 'LockBoxClaimInquiries validator',
        error: "Fill out the required column fields.",
        validate: function(value){
      for(var i = 0; i < value.length; i++){
        if(!value[i].LBChartID || !value[i].LBPatientName || !value[i].LBDOS || !value[i].LBCheckNo || !value[i].LBPaidAmount || !value[i].LBCheckAmount || !value[i].LBCashedClearedDate || !value[i].LBMailedTo || !value[i].LBReasonInquiry){
          return false;
        }
        }
      return true;
        }});
        
       if(value == "Aging") {
             fd.control('AgingClaimInquiries').addValidator({
        name: 'AgingClaimInquiries2 validator',
        error: "Fill out the required column fields.",
        validate: function(value){
      for(var i = 0; i < value.length; i++){
        if(!value[i].AgingChartID || !value[i].AgingPatientName || !value[i].AgingDOS || !value[i].AgingProvider || !value[i].AgingClaimAmount || !value[i].AgingIssueTrakYN || !value[i].AgingReasonInquiry){
          return false;
        }
      }
      return true;
    }});
             }}}
             });

Dear @charlenecapps,
That's not how to use validators - they are added once, and then check for conditions inside, but here you are adding validators on field change.

Instead, try the following:

fd.rendered(() => {
  fd.control('LockBoxClaimInquiries').addValidator({
    name: 'LockBoxClaimInquiries validator',
    error: "Fill out the required column fields.",
    validate: (value) => {
      if(fd.field('InquiryType').value == 'LockBox') {
        if(value.length == 0){
          return false;
        }
        for(var i = 0; i < value.length; i++){
          if(!value[i].LBChartID || !value[i].LBPatientName || !value[i].LBDOS || !value[i].LBCheckNo || !value[i].LBPaidAmount || !value[i].LBCheckAmount || !value[i].LBCashedClearedDate || !value[i].LBMailedTo || !value[i].LBReasonInquiry){
            return false;
          }
        }
      }
      return true;
    }
  });
  fd.control('AgingClaimInquiries').addValidator({
    name: 'AgingClaimInquiries2 validator',
    error: "Fill out the required column fields.",
    validate: (value) => {
      if(fd.field('InquiryType').value == 'Aging') {
        if(value.length == 0){
          return false;
        }
        for(var i = 0; i < value.length; i++){
          if(!value[i].AgingChartID || !value[i].AgingPatientName || !value[i].AgingDOS || !value[i].AgingProvider || !value[i].AgingClaimAmount || !value[i].AgingIssueTrakYN || !value[i].AgingReasonInquiry){
            return false;
          }
        }
      }
      return true;
    }
  });
});