1
 {
        label: "Room",
        name: "room",
        type: "select",
        rule: yup.string().min(1, 'Room field must have at least 1 or more items').required('Room is a required field'),
        renderer: () => {
          const { control, register, errors } = useFormContext();

          return (
            <SelectPicker
              placeholder="Room"
              data={roomList}
              labelKey="name"
              valueKey="row"
              onChange={(value) => {
                control.setValue('room', value)
              }}
              value={control.getValues()['room']?.row}
            />
          )
        }

How to apply the yup validation on the selectpicker, cause after clicking the submit button it doesn't display the error message.

I tried to apply add this

validate={value => {
            if (!value) {
              return "Required";
            }
          }}

on the rsuite selectpicker

  • 1
    You can refer this for an example, hopefully it can give you some insight: https://github.com/syedwshah/InStore/blob/master/server/src/modules/customer/customer.controller.js – Shah Mar 26 '21 at 06:56
  • https://www.npmjs.com/package/yup Has examples on how to do this as well. – Shah Mar 26 '21 at 07:01

0 Answers0