type FormValidationHandler<FormValues> = (params: {
formValues: FormValues,
debugName?: string,
}) => {
isValid: boolean,
fieldErrors: Record<string, unknown>,
formError: string,
}
const validateForm: FormValidationHandler = params => {
// Perform form validation based on params and return result
return {
isValid: true,
fieldErrors: {},
formError: ''
}
}
FormValidationHandler
expects 1 generic argument, and in defining functions the type assignment precedes the generic setup. How can we make use of generics in the validateForm
function and pass it to FormValidationHandler
.
Note: While Parameters
and ReturnType
can be used, I am exploring the possibility of directly assigning the function type itself.