You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
403 B
TypeScript

import { BaseContext } from "koa";
import { Field } from "sealious";
import { FormFieldValidationFn } from "./field";
export function collectionFieldValidator(field: Field): FormFieldValidationFn {
return async (ctx: BaseContext, value) => {
const { valid, reason } = await field.checkValue(ctx.$context, value, undefined);
return { valid, message: reason || (valid ? "Wrong value" : "") };
};
}