UNPKG

e-virt-table

Version:

A powerful data table based on canvas. You can use it as data grid、Microsoft Excel or Google sheets. It supports virtual scroll、cell edit etc.

27 lines (26 loc) 681 B
import { Column } from './types'; export type Rule = { required?: boolean; pattern?: RegExp; validator?: RuleValidator; message?: string; }; export type RuleParam = { field: string; fieldValue: string; value: string; column: Column; colIndex: number; rowIndex: number; row: any; key: string; rowKey: string; } & Rule; export type RuleValidator = (rule: Rule, value: any, callback: (message?: string) => void) => void; export type Rules = Rule[]; export type ValidateResult = RuleParam[]; export default class Validator { private rules; constructor(rules: Rules | Rule); validate(params: RuleParam): ValidateResult; }