'how to setup a validation in custom valid using useForm

how to setup a validation in custom valid using useForm

<label htmlFor="passwordConfirmation">Confirm Password</label>
    <input
        type="password"
        name="confirmPassword"
        className="form-control"
        {...register('confirmPassword',
        {
            required: "Confirm password is required",
            minLength: { value: 6, message: 'Minimum 6 characters required', },
            maxLength: { value: 32, message: 'Maximum 32 length exceeded' },
            validate: { SameAsPassword: SameAsPassword('password', getValues) }
        })}
        id="passwordConfirmation" />

    <ErrorMessage
        errors={errors}
        name="confirmPassword"
        render={({ message }) => <div className="btn btn-danger">{message}</div>}
    />

how to display error message using custom validate using UseForm hooks

SameAsPassword how to display this message using ErrorMessage component provided by useForm. Please guide on this thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source