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

export interface IRegisterFormBody {
	token: string,
	name: string,
	email: string,
	password: string,
	retypePassword: string
}

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