You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
626 B

import {ParameterMiddleware, Injectable, Either, ResponseObject, Validator, Valid, right} from '@extollo/lib'
import {ContactForm} from '../../../types/ContactForm.type'
/**
* ContactForm Middleware
* --------------------------------------------
* Parse the contact form data and validate it. Provide the fields as middleware.
*/
@Injectable()
export class ValidContactForm extends ParameterMiddleware<Valid<ContactForm>> {
async handle(): Promise<Either<ResponseObject, Valid<ContactForm>>> {
const validator = new Validator<ContactForm>()
return right(validator.parse(this.request.input()))
}
}