Skip to content
Discussion options

You must be logged in to vote

Take a look at this codesandbox

<Controller
  control={control}
  name="date"
  rules={{
    validate: {
      min: (date) => isFuture(date) || "Please, enter a future date"
    }
  }}
  render={({ field: { ref, onBlur, name, ...field }, fieldState }) => (
    <DatePicker
      {...field}
      inputRef={ref}
      label="Date"
      renderInput={(inputProps) => (
        <TextField
          {...inputProps}
          onBlur={onBlur}
          name={name}
          error={!!fieldState.error}
          helperText={fieldState.error?.message}
        />
      )}
    />
  )}
/>

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@Moshyfawn
Comment options

@sidneywidmer
Comment options

@rayson1223
Comment options

@pranavgoel29
Comment options

@bablukpik
Comment options

Answer selected by DanPresa
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
8 participants