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

175 lines
3.8 KiB
TypeScript
Raw Normal View History

import { EXECUTION_PARAM_KEY } from "constants/AppsmithActionConstants/ActionConstants";
import { ValidationConfig } from "./PropertyControlConstants";
2020-03-31 03:21:35 +00:00
// Always add a validator function in ./worker/validation for these types
export enum ValidationTypes {
TEXT = "TEXT",
REGEX = "REGEX",
NUMBER = "NUMBER",
BOOLEAN = "BOOLEAN",
OBJECT = "OBJECT",
ARRAY = "ARRAY",
OBJECT_ARRAY = "OBJECT_ARRAY",
NESTED_OBJECT_ARRAY = "NESTED_OBJECT_ARRAY",
DATE_ISO_STRING = "DATE_ISO_STRING",
IMAGE_URL = "IMAGE_URL",
FUNCTION = "FUNCTION",
2021-07-28 06:01:09 +00:00
SAFE_URL = "SAFE_URL",
TABLE_PROPERTY = "TABLE_PROPERTY",
}
2019-11-22 13:12:39 +00:00
export type ValidationResponse = {
isValid: boolean;
parsed: any;
messages?: string[];
2020-06-05 16:20:23 +00:00
transformed?: any;
2019-11-19 12:44:58 +00:00
};
2020-04-20 05:42:46 +00:00
export type Validator = (
config: ValidationConfig,
value: unknown,
props: Record<string, unknown>,
feat: JSON Form widget (#8472) * initial layout * updated parser to support nested array * array field rendering * changes * ts fix * minor revert FormWidget * modified schema structure * select and switch fields * added checkbox field * added RadioGroupField * partial DateField and defaults, typing refactoring * added label and field type change * minor ts changes * changes * modified widget/utils for nested panelConfig, modified schema to object approach * array/object label support * hide field configuration when children not present * added tooltip * field visibility option * disabled state * upgraded tslib, form initial values * custom field configuration - add/hide/edit * field configuration - label change * return input when field configuration reaches max depth * minor changes * form - scroll, fixedfooter, enitity defn and other minior changes * form title * unregister on unmount * fixes * zero state * fix field padding * patched updating form values, removed linting warnings * configured action buttons * minor fix * minor change * property pane - sort fields in field configuration * refactor include all properties * checkbox properties * date properties * refactor typings and radio group properties * switch, multselect, select, array, object properties * minor changes * default value * ts fixes * checkbox field properties implementation * date field prop implementation * switch field * select field and fix deep nested meta properties * multiselect implementation * minor change * input field implementation * fix position jump on field type change * initial accordian * field state property and auto-complete of JSONFormComputeControl * merge fixes * renamed FormBuilder to JSONForm * source data validation minor change * custom field default value fix * Editable keys for custom field * minor fixes * replaced useFieldArray with custom logic, added widget icon * array and object accordian with border/background styling * minor change * disabled states for array and objects * default value minor fix * form level styles * modified logic for isDisabled for array and object, added disabledWhenInvalid, exposed isValid to fieldState for text input, removed useDisableChildren * added isValid for all field types * fixed reset to default values * debounce form values update * minor change * minor change * fix crash - source data change multi-select to array, fix crash - change of options * fix positioning * detect date type in source data * fix crash - when object is passed to regex input field * fixed default sourceData path for fields * accodion keep children mounted on collapse * jest test for schemaParser * widget/helper and useRegisterFieldInvalid test * tests for property config helper and generatePanelPropertyConfig * fix input field validation not appearing * fix date field type detection * rename data -> formData * handle null/undefined field value change in sourceData * added null/undefined as valid values for defaultValue text field * auto detect email field * set formData default value on initial load * switch field inline positioning * field margin fix for row direction * select full width * fiex date field default value - out of range * fix any field type to array * array default value logic change * base cypress test changes * initial json form render cy test * key sanitization * fix fieldState update logic * required design, object/array background color, accordion changes, fix - add new custom field * minor change * cypress tests * fix date formatted value, field state cypress test * cypress - field properties test and fixes * rename test file * fix accessort change to blank value, cypress tests * fix array field default value for modified accessor * minor fix * added animate loading * fix empty state, add new custom field * test data fix * fix warnings * fix timePrecision visibility * button styling * ported input v2 * fix jest tests * fix cypress tests * perf changes * perf improvement * added comments * multiselect changes * input field perf refactor * array field, object field refactor performance * checkbox field refactor * refectored date, radio, select and switch * fixes * test fixes * fixes * minor fix * rename field renderer * remove tracked fieldRenderer field * cypress test fixes * cypress changes * array default value fixes * arrayfield passedDefaultValue * auto enabled JS mode for few properties, reverted swith and date property controls * cypress changes * added widget sniping mode and fixed object passedDefaultValue * multiselect v2 * select v2 * fix jest tests * test fixes * field limit * rename field type dropdown texts * field type changes fixes * jest fixes * loading state submit button * default source data for new widget * modify limit message * multiseelct default value changes and cypress fix * select default value * keep default value intact on field type change * TextTable cypress text fix * review changes * fixed footer changes * collapse styles section by default * fixed footer changes * form modes * custom field key rentention * fixed footer fix in view mode * non ascii characters * fix meta merge in dataTreeWidget * minor fixes * rename useRegisterFieldInvalid.ts -> useRegisterFieldValidity.ts * modified dependency injection into evaluated values * refactored fixedfooter logic * minor change * accessor update * minor change * fixes * QA fixes date field, scroll content * fix phone number field, removed visiblity option from array item * fix sourceData autocomplete * reset logic * fix multiselect reset * form values hydration on widget drag * code review changes * reverted order of merge dataTreeWidget * fixes * added button titles, fixed hydration issue * default value fixes * upgraded react hook form, modified array-level/field-level default value logic * fixed select validation * added icon entity explorer, modified icon align control * modify accessor validation for mongo db _id * update email field regex * review changes * explicitly handle empty source data validation
2022-03-24 07:13:25 +00:00
propertyPath: string,
2020-04-20 05:42:46 +00:00
) => ValidationResponse;
export const ISO_DATE_FORMAT = "YYYY-MM-DDTHH:mm:ss.sssZ";
2020-12-14 18:48:13 +00:00
export const JAVASCRIPT_KEYWORDS = {
Array: "Array",
await: "await",
Boolean: "Boolean",
break: "break",
case: "case",
catch: "catch",
class: "class",
const: "const",
continue: "continue",
Date: "Date",
debugger: "debugger",
default: "default",
delete: "delete",
do: "do",
else: "else",
enum: "enum",
eval: "eval",
export: "export",
extends: "extends",
false: "false",
finally: "finally",
for: "for",
function: "function",
Function: "Function",
hasOwnProperty: "hasOwnProperty",
if: "if",
implements: "implements",
import: "import",
in: "in",
Infinity: "Infinity",
instanceof: "instanceof",
interface: "interface",
isFinite: "isFinite",
isNaN: "isNaN",
isPrototypeOf: "isPrototypeOf",
JSON: "JSON",
length: "length",
let: "let",
Math: "Math",
name: "name",
NaN: "NaN",
new: "new",
null: "null",
Number: "Number",
Object: "Object",
package: "package",
private: "private",
protected: "protected",
public: "public",
return: "return",
static: "static",
String: "String",
super: "super",
switch: "switch",
this: "this",
throw: "throw",
toString: "toString",
true: "true",
try: "try",
typeof: "typeof",
undefined: "undefined",
valueOf: "valueOf",
var: "var",
void: "void",
while: "while",
with: "with",
yield: "yield",
};
2020-12-14 18:48:13 +00:00
export const DATA_TREE_KEYWORDS = {
actionPaths: "actionPaths",
appsmith: "appsmith",
pageList: "pageList",
[EXECUTION_PARAM_KEY]: EXECUTION_PARAM_KEY,
};
export const WINDOW_OBJECT_PROPERTIES = {
closed: "closed",
console: "console",
defaultStatus: "defaultStatus",
document: "document",
frameElement: "frameElement",
frames: "frames",
history: "history",
innerHeight: "innerHeight",
innerWidth: "innerWidth",
length: "length",
localStorage: "localStorage",
location: "location",
name: "name",
navigator: "navigator",
opener: "opener",
outerHeight: "outerHeight",
outerWidth: "outerWidth",
pageXOffset: "pageXOffset",
pageYOffset: "pageYOffset",
parent: "parent",
screen: "screen",
screenLeft: "screenLeft",
screenTop: "screenTop",
screenY: "screenY",
scrollX: "scrollX",
scrollY: "scrollY",
self: "self",
status: "status",
top: "top",
evaluationVersion: "evaluationVersion",
};
export const WINDOW_OBJECT_METHODS = {
alert: "alert",
atob: "atob",
blur: "blur",
btoa: "btoa",
clearInterval: "clearInterval",
clearTimeout: "clearTimeout",
close: "close",
confirm: "confirm",
focus: "focus",
getComputedStyle: "getComputedStyle",
getSelection: "getSelection",
matchMedia: "matchMedia",
moveBy: "moveBy",
moveTo: "moveTo",
open: "open",
print: "print",
prompt: "prompt",
requestAnimationFrame: "requestAnimationFrame",
resizeBy: "resizeBy",
resizeTo: "resizeTo",
scroll: "scroll",
scrollBy: "scrollBy",
scrollTo: "scrollBy",
setInterval: "setInterval",
setTimeout: "setTimeout",
stop: "stop",
};