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

90 lines
2.0 KiB
TypeScript
Raw Normal View History

2020-03-31 03:21:35 +00:00
import { WidgetProps } from "widgets/BaseWidget";
2020-04-20 05:42:46 +00:00
import { DataTree } from "entities/DataTree/dataTreeFactory";
2020-03-31 03:21:35 +00:00
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",
2020-04-03 02:42:45 +00:00
REGEX: "REGEX",
2019-11-19 12:44:58 +00:00
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",
DEFAULT_DATE: "DEFAULT_DATE",
TABS_DATA: "TABS_DATA",
2020-03-13 12:06:41 +00:00
CHART_DATA: "CHART_DATA",
2020-04-15 11:42:11 +00:00
MARKERS: "MARKERS",
2020-03-31 10:40:52 +00:00
ACTION_SELECTOR: "ACTION_SELECTOR",
ARRAY_ACTION_SELECTOR: "ARRAY_ACTION_SELECTOR",
SELECTED_TAB: "SELECTED_TAB",
DEFAULT_OPTION_VALUE: "DEFAULT_OPTION_VALUE",
DEFAULT_SELECTED_ROW: "DEFAULT_SELECTED_ROW",
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;
2020-06-05 16:20:23 +00:00
transformed?: any;
2019-11-19 12:44:58 +00:00
};
export type ValidationType = typeof VALIDATION_TYPES[keyof typeof VALIDATION_TYPES];
2020-04-20 05:42:46 +00:00
export type Validator = (
value: any,
props: WidgetProps,
dataTree?: DataTree,
) => ValidationResponse;
export const ISO_DATE_FORMAT = "YYYY-MM-DDTHH:mm:ss.SSSZ";
export const JAVSCRIPT_KEYWORDS = {
true: "true",
await: "await",
break: "break",
case: "case",
catch: "catch",
class: "class",
const: "const",
continue: "continue",
debugger: "debugger",
default: "default",
delete: "delete",
do: "do",
else: "else",
enum: "enum",
export: "export",
extends: "extends",
false: "false",
finally: "finally",
for: "for",
function: "function",
if: "if",
implements: "implements",
import: "import",
in: "in",
instanceof: "instanceof",
interface: "interface",
let: "let",
new: "new",
null: "null",
package: "package",
private: "private",
protected: "protected",
public: "public",
return: "return",
static: "static",
super: "super",
switch: "switch",
this: "this",
throw: "throw",
try: "try",
typeof: "typeof",
var: "var",
void: "void",
while: "while",
with: "with",
yield: "yield",
};