HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/fintechfuel/src/routes/api/send/Validation.ts
import type { IRequest } from '../../../type/form';

const Validation = (value: IRequest) => {
  const error: { [name: string]: string } = {};

  if (Object.values(value).length) {
    if (value['email'] === undefined || value['email'] === '') {
      error['email'] = 'Required';
    } else {
      if (
        !value['email'].match(
          /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
        )
      ) {
        error['email'] = 'Must be a valid email';
      }
    }
    if (value['name'] === undefined || value['name'] === '') {
      error['name'] = 'Required';
    }
    // if (value['message'] === undefined || value['message'] === '') {
    //   error['message'] = 'Required';
    // }

    if (value['price'] === undefined || value['price'] === '') {
      error['price'] = 'Required';
    }
    if (value['phone'] === undefined || value['phone'] === '') {
      error['phone'] = 'Required';
    } else {
      if (!value['phone'].match(/^[\d\+][\d\(\)\ -]{4,14}\d$/)) {
        error['phone'] = 'Not valid phone number';
      }
    }
  } else {
    error['email'] = 'Required';
    error['name'] = 'Required';
    error['message'] = 'Required';
    error['price'] = 'Required';
    error['phone'] = 'Required';
  }

  return error;
};

export default Validation;