private customValidateForm()

in frontend/src/app/modules/config-editor/components/config-editor/config-editor.component.ts [415:492]


  private customValidateForm(form: FormGroup) {
    if(form.get('asm_config_values')?.value.length < 1 && !this.getNamesFromAsm(form)){
      this.openSnackBar('ERROR! : You must create at least one ASM configurations' , 'OK');
      return false;
    }

    if(this.diskSizeValidator().length){
      this.diskSizeValidator().forEach((e: errorInfo)  => {
        this.openSnackBar(`ERROR! : the maximum size of the disks that may be added to a diskgroup should not exceed ${e.value} bg` , 'OK');
      })
      return false;
    }


    if (!this.configEditorForm.get('misc_config_values')?.get('swap_blk_device')?.value &&
       !this.configEditorForm.get('misc_config_values')?.get('is_swap_configured')?.value &&
       Number(this.oracle_version) < 18) {
         this.openSnackBar('ERROR! : The swap configuration is required for oracle versions less the 18', 'OK');
         return false;
    }

    const checkSwapError = () => {
      return this.ldspFaDevices.controls.some((control) => control.get('purpose')?.hasError('swapIsAlreadyConfigured')) ||
      this.configEditorForm.get('misc_config_values')?.get('is_swap_configured')?.hasError('swapIsAlreadyConfigured');
    }
    if (checkSwapError()) {
      this.openSnackBar('ERROR! : swap configuration is wrong' , 'OK');
      return false;
    }

    const dublicatePurposesCheck = () => this.ldspFaDevices.controls.some((control) => control.get('purpose')?.hasError('incorrect'));
    if (dublicatePurposesCheck()) {
      this.openSnackBar('ERROR! : the local data parameter purpose is dublicated' , 'OK');
      return false;
    }

    const scanIpDublicateCheck = () => {
      return form.get('rac_config_values')?.get('scan_ip2')?.hasError('notUnique') ||
      form.get('rac_config_values')?.get('scan_ip3')?.hasError('notUnique');
    }

    const isVipIpDublicate = this.racNodes?.controls.some(element => {
      return element.get('vip_ip')?.hasError('notUnique');
    });

    if (isVipIpDublicate) {
      this.openSnackBar('ERROR! : VIP IP has to be unique' , 'OK');
      this.isInvalid = true;
      return false;
    }

    if (scanIpDublicateCheck()) {
      this.openSnackBar('ERROR! : SCAN IP-Address has to be unique' , 'OK');
      this.isInvalid = true;
      return false;
    }

    const mountPointCheck = () => this.ldspFaDevices.controls.some((control) => control.get('mount_point')?.hasError('notUnique'));
    if (mountPointCheck()) {
      this.openSnackBar('ERROR! : the local data parameter mount point has to be unique' , 'OK');
      this.isInvalid = true;
      return false;
    }

    if (form.get('misc_config_values')?.get('ntp_preferred')?.hasError('invalidFormat')) {
      this.openSnackBar('ERROR! : Preferred NTP server must be either of IP address or domain.com(domain.gov.com) type' , 'OK');
      this.isInvalid = true;
      return false;
    }

    if (!form.valid) {
      this.openSnackBar('ERROR! : missing fields' , 'OK');
      this.isInvalid = true;
      return false;
    }

    return  true
  }