import * as Yup from 'yup'
import {DailyLog_Enums} from '../../../../redux/helpers/action-enums'
export const validators = Yup.object({

    logDate: Yup.string()
      .required('Log date is required'),
    logTime: Yup.string()
      .required('Log time is required'),   
    details: Yup.string()
          .required('Details is required')
          .test({
            name: 'BP-format-test',
            message: 'Enter ${path} in correct format, e.g. 120/80',
            test: function (value) {
              // You can access the logType field with `this.parent`.
              if(parseInt(this.parent.logType) === parseInt(DailyLog_Enums.DailyLogsCTEnum.BloodPressure)){

                const regx = RegExp(/^\d{1,3}\/\d{1,3}$/)
                return regx.test(value)
              }else {
                return true
              }              
            }
          }),
    // comments: Yup.string()
      // .required('Comments is required'),   
    logType: Yup.string()        
      .required('Log type is required')
  })

