import { DEMAND_ADVERTISER_PAGE_CONFIG_TAB_SETTINGS_ID } from '@/modules/marketplace/account/constants';

export const validationScheme = [
  {
    fieldName: 'advertiserSettings.name',
    tabId: DEMAND_ADVERTISER_PAGE_CONFIG_TAB_SETTINGS_ID,
    validation: (value: string) => {
      if (!value) {
        return 'Field cannot be empty';
      }

      return '';
    },
  },
  {
    fieldName: 'advertiserSettings.demandAccountId',
    tabId: DEMAND_ADVERTISER_PAGE_CONFIG_TAB_SETTINGS_ID,
    validation: (value: string, store: { pageConfig: { isCreateNew: boolean } }) => {
      if (!store.pageConfig.isCreateNew) {
        return '';
      }

      if (!value) {
        return 'Field cannot be empty';
      }

      return '';
    },
  },
  {
    fieldName: 'advertiserSettings.frequencyCapAdjustmentThreshold',
    tabId: DEMAND_ADVERTISER_PAGE_CONFIG_TAB_SETTINGS_ID,
    validation: (value: number) => {
      if (!value) {
        return 'Field cannot be empty';
      }

      return '';
    },
  },
];
