我有以下由分子框架创建的api,有EventDate参数,我如何指定格式并应用验证规则来检查接收日期
createEvent: {
params: {
UserId: {
type: "string",
optional: false
},
Name: {
type: "string",
optional: false
},
Description: {
type: "string",
optional: false
},
Location: {
type: "string",
optional: false
},
EventDate: {
type: "string",
optional: false
}
},
handler(ctx) {
let entity = ctx.params;
return this.broker.call("event.find", {
query: {
UserId: entity.UserId,
Name: entity.Name,
}
}).then((res) => {
if (res == null || res.length == 0) {
return this.broker.call("event.create",{
UserId:entity.UserId,
Location: entity.Location,
EventDate: entity.EventDate,
Description: entity.Description,
Name:entity.Name
}).then(doc =>{
return new Response(200, 'success', doc);
});
} else {
throw new ValidationError("you already created event with same name", -1, "you already created event with same name");
}
});
}
},
我只想接受这种日期格式 yyyy/mm/dd