import validate from "validate.js";
import { MiddlewareRequest } from "../middleware";
import { IAuthMiddlewareParams } from "../middleware/auth";
import { RequestMovieRequest } from "./RequestMovieRequest";

export class RequestImdbMovieRequest<T extends IAuthMiddlewareParams> extends RequestMovieRequest<T>
{
	public validate(request: MiddlewareRequest<T>) {
		return validate.async(request.params, {
			imdb_id: {
				presence: {
					allowEmpty: false,
					message: "IMDb ID is required"
				},
				format: {
					pattern: "tt[0-9]+",
					message: "Invalid IMDb ID"
				}
			}
		},<any>{ fullMessages: false });
	}
}
