import { ValidationConstraints as constraints } from "@autoplex-api/request";
import { Request } from "@autoplex/webserver";
import { FastifyRequest } from "fastify";
import validate from "validate.js";

export interface ILoginFormBody {
	email: string,
	password: string
}

export class LoginRequest extends Request
{
	/**
	 * Validate the request
	 */
	public validate(request: FastifyRequest) {
		return validate.async(request.body, {
			email: constraints.login.email,
			password: constraints.login.password,
		},<any>{ fullMessages: false });
	}
}
