PromucFlow_constructor/app/client/src/constants/WidgetValidation.ts

26 lines
704 B
TypeScript
Raw Normal View History

2020-03-31 03:21:35 +00:00
import { WidgetProps } from "widgets/BaseWidget";
2019-11-22 13:12:39 +00:00
// Always add a validator function in ./Validators for these types
2019-11-19 12:44:58 +00:00
export const VALIDATION_TYPES = {
TEXT: "TEXT",
NUMBER: "NUMBER",
BOOLEAN: "BOOLEAN",
OBJECT: "OBJECT",
2019-11-22 13:12:39 +00:00
ARRAY: "ARRAY",
2019-11-19 12:44:58 +00:00
TABLE_DATA: "TABLE_DATA",
2020-02-03 11:49:20 +00:00
OPTIONS_DATA: "OPTIONS_DATA",
2019-11-22 13:12:39 +00:00
DATE: "DATE",
2020-03-13 12:06:41 +00:00
CHART_DATA: "CHART_DATA",
2020-03-31 10:40:52 +00:00
ACTION_SELECTOR: "ACTION_SELECTOR",
ARRAY_ACTION_SELECTOR: "ARRAY_ACTION_SELECTOR",
2019-11-22 13:12:39 +00:00
};
export type ValidationResponse = {
isValid: boolean;
parsed: any;
2019-12-10 13:30:16 +00:00
message?: string;
2019-11-19 12:44:58 +00:00
};
export type ValidationType = typeof VALIDATION_TYPES[keyof typeof VALIDATION_TYPES];
2020-03-31 03:21:35 +00:00
export type Validator = (value: any, props?: WidgetProps) => ValidationResponse;