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.
 
 
 
 
 
 

37 lines
971 B

import { FastifyRequest } from "fastify";
import validate from "validate.js";
import { RegisterToken } from "@server/database/entities";
import { hasAllProperties } from "@server/util";
import { constraints } from "@common/validation";
import Request from "./Request";
interface IRegisterFormBody {
token: string,
name: string,
email: string,
password: string,
retypePassword: string
}
export default class RegisterRequest extends Request
{
/**
* Validate the request
*/
public validate(request: FastifyRequest) {
// let body = <IRegisterFormBody>request.body;
// if (!RegisterToken.isValid(body.token)) {
// return {
// "token": "Invalid token"
// }
// }
console.log("Validating a request");
return validate.async(request.body, {
token: constraints.token,
name: constraints.name,
email: constraints.email,
password: constraints.password,
retypePassword: constraints.retypePassword
}, <any>{ fullMessages: false });
}
}