@defra/forms-model 3.0.693 → 3.0.694
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module/form/form-manager/errors.js +32 -0
- package/dist/module/form/form-manager/errors.js.map +1 -1
- package/dist/types/form/form-manager/errors.d.ts +6 -0
- package/dist/types/form/form-manager/errors.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/form/form-manager/errors.ts +56 -0
|
@@ -93,4 +93,36 @@ export function getErrors(validationError) {
|
|
|
93
93
|
};
|
|
94
94
|
}) ?? [];
|
|
95
95
|
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Human-readable messages for each {@link FormDefinitionError} code, shared
|
|
99
|
+
* by services that surface definition-validation failures (designer editor
|
|
100
|
+
* flows, runner preview error pages).
|
|
101
|
+
*/
|
|
102
|
+
export const formErrorsToMessages = {
|
|
103
|
+
[FormDefinitionError.UniquePageId]: 'Each page must have a unique ID. Change the page ID to one that is not already used.',
|
|
104
|
+
[FormDefinitionError.UniquePagePath]: 'Each page must have a unique path. Change the page path to one that is not already used.',
|
|
105
|
+
[FormDefinitionError.UniquePageComponentId]: 'Each question on a page must have a unique ID. Change the question ID to one that is not already used.',
|
|
106
|
+
[FormDefinitionError.UniquePageComponentName]: 'Each question on a page must have a unique name. Change the question name to one that is not already used.',
|
|
107
|
+
[FormDefinitionError.UniqueSectionId]: 'Each section must have a unique ID. Change the section ID to one that is not already used.',
|
|
108
|
+
[FormDefinitionError.UniqueSectionName]: 'Each section must have a unique name. Change the section name to one that is not already used.',
|
|
109
|
+
[FormDefinitionError.UniqueSectionTitle]: 'Each section must have a unique title. Change the section title to one that is not already used.',
|
|
110
|
+
[FormDefinitionError.UniqueListId]: 'Each list must have a unique ID. Change the list ID to one that is not already used.',
|
|
111
|
+
[FormDefinitionError.UniqueListTitle]: 'Each list must have a unique title. Change the list title to one that is not already used.',
|
|
112
|
+
[FormDefinitionError.UniqueListName]: 'Each list must have a unique name. Change the list name to one that is not already used.',
|
|
113
|
+
[FormDefinitionError.UniqueConditionId]: 'Each condition must have a unique ID. Change the condition ID to one that is not already used.',
|
|
114
|
+
[FormDefinitionError.UniqueConditionDisplayName]: 'Each condition must have a unique display name. Change the display name to one that is not already used.',
|
|
115
|
+
[FormDefinitionError.UniqueListItemId]: 'Each item in a list must have a unique ID. Change the item ID to one that is not already used.',
|
|
116
|
+
[FormDefinitionError.UniqueListItemText]: 'Each item in a list must have unique text. Change the item text to one that is not already used.',
|
|
117
|
+
[FormDefinitionError.UniqueListItemValue]: 'Each item in a list must have a unique value. Change the item value to one that is not already used.',
|
|
118
|
+
[FormDefinitionError.RefPageCondition]: 'This page is referenced by a condition. Remove the condition before making changes to this page.',
|
|
119
|
+
[FormDefinitionError.RefConditionComponentId]: 'Remove the condition before deleting this page',
|
|
120
|
+
[FormDefinitionError.RefConditionListId]: 'A condition is using a list in this form. Remove the condition before making changes to the list.',
|
|
121
|
+
[FormDefinitionError.RefConditionItemId]: 'A condition is using an item in this list. Remove the condition before making changes to the item.',
|
|
122
|
+
[FormDefinitionError.RefConditionConditionId]: 'A condition is using another condition. Remove the reference before making changes.',
|
|
123
|
+
[FormDefinitionError.RefPageComponentList]: 'A question on this page is using a list. Remove the reference before making changes to the list.',
|
|
124
|
+
[FormDefinitionError.IncompatibleConditionComponentType]: 'You cannot change to this question type because this question is used in a condition. Remove the condition or select a different question type.',
|
|
125
|
+
[FormDefinitionError.IncompatibleQuestionRegex]: 'The regex expression is invalid',
|
|
126
|
+
[FormDefinitionError.Other]: 'There is a problem with the form definition. Check your changes and try again.'
|
|
127
|
+
};
|
|
96
128
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":["FormDefinitionError","FormDefinitionErrorType","formDefinitionErrors","checkErrors","formErrors","possibleErrors","Array","isArray","errors","forEach","err","local","errorType","formError","errorDetails","keyMatch","key","path","type","Unique","code","errorCode","Ref","Incompatible","Type","getErrors","validationError","details","map","detail","context","id","message","pos","dupePos","valueKey","value","label","incompatibleObject","reason","Other"],"sources":["../../../../src/form/form-manager/errors.ts"],"sourcesContent":["import type Joi from 'joi'\nimport { type ValidationError } from 'joi'\n\nimport {\n FormDefinitionError,\n FormDefinitionErrorType,\n formDefinitionErrors,\n type FormDefinitionErrorCause\n} from '~/src/form/form-manager/types.js'\n\n/**\n * Checks and applies an `errorType` and also an `errorCode` for known errors\n */\nexport const checkErrors = (\n formErrors: FormDefinitionError | FormDefinitionError[]\n) => {\n const possibleErrors = Array.isArray(formErrors) ? formErrors : [formErrors]\n\n return function (errors: Joi.ErrorReport[]) {\n errors.forEach((err) => {\n if (err.local.errorType) {\n return\n }\n\n for (const formError of possibleErrors) {\n const errorDetails = formDefinitionErrors[formError]\n\n // Joi's `context.key` will be the index for arrays\n // in which case use the path, otherwise use the key\n const keyMatch =\n typeof err.local.key === 'number' ? err.local.path : err.local.key\n\n if (\n errorDetails.type === FormDefinitionErrorType.Unique &&\n err.code === 'array.unique' &&\n keyMatch === errorDetails.key\n ) {\n err.local.errorCode = formError\n err.local.errorType = FormDefinitionErrorType.Unique\n return\n }\n\n if (\n errorDetails.type === FormDefinitionErrorType.Ref &&\n err.code === 'any.only' &&\n keyMatch === errorDetails.key\n ) {\n err.local.errorCode = formError\n err.local.errorType = FormDefinitionErrorType.Ref\n return\n }\n\n if (\n errorDetails.type === FormDefinitionErrorType.Incompatible &&\n err.code === 'custom.incompatible'\n // Match any key\n ) {\n err.local.errorCode = formError\n err.local.errorType = FormDefinitionErrorType.Incompatible\n return\n }\n\n err.local.errorType = FormDefinitionErrorType.Type\n }\n })\n return errors\n }\n}\n\n/**\n * Get the custom errors from a form definition joi validation error\n */\nexport function getErrors(\n validationError: ValidationError | undefined\n): FormDefinitionErrorCause[] {\n return (\n validationError?.details.map((detail) => {\n if (\n detail.context?.errorType === FormDefinitionErrorType.Unique &&\n detail.context.errorCode\n ) {\n return {\n id: /** @type {FormDefinitionError} */ detail.context.errorCode,\n type: FormDefinitionErrorType.Unique,\n message: detail.message,\n detail: {\n path: detail.path,\n pos: detail.context.pos,\n dupePos: detail.context.dupePos\n }\n }\n }\n\n if (\n detail.context?.errorType === FormDefinitionErrorType.Ref &&\n detail.context.errorCode\n ) {\n return {\n id: /** @type {FormDefinitionError} */ detail.context.errorCode,\n type: FormDefinitionErrorType.Ref,\n message: detail.message,\n detail: {\n path: detail.path\n }\n }\n }\n\n if (\n detail.context?.errorType === FormDefinitionErrorType.Incompatible &&\n detail.context.errorCode\n ) {\n return {\n id: /** @type {FormDefinitionError} */ detail.context.errorCode,\n type: FormDefinitionErrorType.Incompatible,\n message: detail.message,\n detail: {\n path: detail.path,\n key: detail.context.key,\n valueKey: detail.context.valueKey,\n value: detail.context.value,\n label: detail.context.label,\n incompatibleObject: detail.context.incompatibleObject,\n reason: detail.context.reason\n }\n }\n }\n\n // Catch all others\n return {\n id: FormDefinitionError.Other,\n type: FormDefinitionErrorType.Type,\n message: detail.message,\n detail: detail.context\n }\n }) ?? []\n )\n}\n"],"mappings":"AAGA,SACEA,mBAAmB,EACnBC,uBAAuB,EACvBC,oBAAoB;;AAItB;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GACtBC,UAAuD,IACpD;EACH,MAAMC,cAAc,GAAGC,KAAK,CAACC,OAAO,CAACH,UAAU,CAAC,GAAGA,UAAU,GAAG,CAACA,UAAU,CAAC;EAE5E,OAAO,UAAUI,MAAyB,EAAE;IAC1CA,MAAM,CAACC,OAAO,CAAEC,GAAG,IAAK;MACtB,IAAIA,GAAG,CAACC,KAAK,CAACC,SAAS,EAAE;QACvB;MACF;MAEA,KAAK,MAAMC,SAAS,IAAIR,cAAc,EAAE;QACtC,MAAMS,YAAY,GAAGZ,oBAAoB,CAACW,SAAS,CAAC;;QAEpD;QACA;QACA,MAAME,QAAQ,GACZ,OAAOL,GAAG,CAACC,KAAK,CAACK,GAAG,KAAK,QAAQ,GAAGN,GAAG,CAACC,KAAK,CAAC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DC,MAAM,EAAEV,MAAM,CAACC,OAAO,CAACS;QACzB;MACF,CAAC;IACH;;IAEA;IACA,OAAO;MACLR,EAAE,EAAE/B,mBAAmB,CAACwC,KAAK;MAC7BtB,IAAI,EAAEjB,uBAAuB,CAACuB,IAAI;MAClCQ,OAAO,EAAEH,MAAM,CAACG,OAAO;MACvBH,MAAM,EAAEA,MAAM,CAACC;IACjB,CAAC;EACH,CAAC,CAAC,IAAI,EAAE;AAEZ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"errors.js","names":["FormDefinitionError","FormDefinitionErrorType","formDefinitionErrors","checkErrors","formErrors","possibleErrors","Array","isArray","errors","forEach","err","local","errorType","formError","errorDetails","keyMatch","key","path","type","Unique","code","errorCode","Ref","Incompatible","Type","getErrors","validationError","details","map","detail","context","id","message","pos","dupePos","valueKey","value","label","incompatibleObject","reason","Other","formErrorsToMessages","UniquePageId","UniquePagePath","UniquePageComponentId","UniquePageComponentName","UniqueSectionId","UniqueSectionName","UniqueSectionTitle","UniqueListId","UniqueListTitle","UniqueListName","UniqueConditionId","UniqueConditionDisplayName","UniqueListItemId","UniqueListItemText","UniqueListItemValue","RefPageCondition","RefConditionComponentId","RefConditionListId","RefConditionItemId","RefConditionConditionId","RefPageComponentList","IncompatibleConditionComponentType","IncompatibleQuestionRegex"],"sources":["../../../../src/form/form-manager/errors.ts"],"sourcesContent":["import type Joi from 'joi'\nimport { type ValidationError } from 'joi'\n\nimport {\n FormDefinitionError,\n FormDefinitionErrorType,\n formDefinitionErrors,\n type FormDefinitionErrorCause\n} from '~/src/form/form-manager/types.js'\n\n/**\n * Checks and applies an `errorType` and also an `errorCode` for known errors\n */\nexport const checkErrors = (\n formErrors: FormDefinitionError | FormDefinitionError[]\n) => {\n const possibleErrors = Array.isArray(formErrors) ? formErrors : [formErrors]\n\n return function (errors: Joi.ErrorReport[]) {\n errors.forEach((err) => {\n if (err.local.errorType) {\n return\n }\n\n for (const formError of possibleErrors) {\n const errorDetails = formDefinitionErrors[formError]\n\n // Joi's `context.key` will be the index for arrays\n // in which case use the path, otherwise use the key\n const keyMatch =\n typeof err.local.key === 'number' ? err.local.path : err.local.key\n\n if (\n errorDetails.type === FormDefinitionErrorType.Unique &&\n err.code === 'array.unique' &&\n keyMatch === errorDetails.key\n ) {\n err.local.errorCode = formError\n err.local.errorType = FormDefinitionErrorType.Unique\n return\n }\n\n if (\n errorDetails.type === FormDefinitionErrorType.Ref &&\n err.code === 'any.only' &&\n keyMatch === errorDetails.key\n ) {\n err.local.errorCode = formError\n err.local.errorType = FormDefinitionErrorType.Ref\n return\n }\n\n if (\n errorDetails.type === FormDefinitionErrorType.Incompatible &&\n err.code === 'custom.incompatible'\n // Match any key\n ) {\n err.local.errorCode = formError\n err.local.errorType = FormDefinitionErrorType.Incompatible\n return\n }\n\n err.local.errorType = FormDefinitionErrorType.Type\n }\n })\n return errors\n }\n}\n\n/**\n * Get the custom errors from a form definition joi validation error\n */\nexport function getErrors(\n validationError: ValidationError | undefined\n): FormDefinitionErrorCause[] {\n return (\n validationError?.details.map((detail) => {\n if (\n detail.context?.errorType === FormDefinitionErrorType.Unique &&\n detail.context.errorCode\n ) {\n return {\n id: /** @type {FormDefinitionError} */ detail.context.errorCode,\n type: FormDefinitionErrorType.Unique,\n message: detail.message,\n detail: {\n path: detail.path,\n pos: detail.context.pos,\n dupePos: detail.context.dupePos\n }\n }\n }\n\n if (\n detail.context?.errorType === FormDefinitionErrorType.Ref &&\n detail.context.errorCode\n ) {\n return {\n id: /** @type {FormDefinitionError} */ detail.context.errorCode,\n type: FormDefinitionErrorType.Ref,\n message: detail.message,\n detail: {\n path: detail.path\n }\n }\n }\n\n if (\n detail.context?.errorType === FormDefinitionErrorType.Incompatible &&\n detail.context.errorCode\n ) {\n return {\n id: /** @type {FormDefinitionError} */ detail.context.errorCode,\n type: FormDefinitionErrorType.Incompatible,\n message: detail.message,\n detail: {\n path: detail.path,\n key: detail.context.key,\n valueKey: detail.context.valueKey,\n value: detail.context.value,\n label: detail.context.label,\n incompatibleObject: detail.context.incompatibleObject,\n reason: detail.context.reason\n }\n }\n }\n\n // Catch all others\n return {\n id: FormDefinitionError.Other,\n type: FormDefinitionErrorType.Type,\n message: detail.message,\n detail: detail.context\n }\n }) ?? []\n )\n}\n\n/**\n * Human-readable messages for each {@link FormDefinitionError} code, shared\n * by services that surface definition-validation failures (designer editor\n * flows, runner preview error pages).\n */\nexport const formErrorsToMessages: Record<FormDefinitionError, string> = {\n [FormDefinitionError.UniquePageId]:\n 'Each page must have a unique ID. Change the page ID to one that is not already used.',\n [FormDefinitionError.UniquePagePath]:\n 'Each page must have a unique path. Change the page path to one that is not already used.',\n [FormDefinitionError.UniquePageComponentId]:\n 'Each question on a page must have a unique ID. Change the question ID to one that is not already used.',\n [FormDefinitionError.UniquePageComponentName]:\n 'Each question on a page must have a unique name. Change the question name to one that is not already used.',\n [FormDefinitionError.UniqueSectionId]:\n 'Each section must have a unique ID. Change the section ID to one that is not already used.',\n [FormDefinitionError.UniqueSectionName]:\n 'Each section must have a unique name. Change the section name to one that is not already used.',\n [FormDefinitionError.UniqueSectionTitle]:\n 'Each section must have a unique title. Change the section title to one that is not already used.',\n [FormDefinitionError.UniqueListId]:\n 'Each list must have a unique ID. Change the list ID to one that is not already used.',\n [FormDefinitionError.UniqueListTitle]:\n 'Each list must have a unique title. Change the list title to one that is not already used.',\n [FormDefinitionError.UniqueListName]:\n 'Each list must have a unique name. Change the list name to one that is not already used.',\n [FormDefinitionError.UniqueConditionId]:\n 'Each condition must have a unique ID. Change the condition ID to one that is not already used.',\n [FormDefinitionError.UniqueConditionDisplayName]:\n 'Each condition must have a unique display name. Change the display name to one that is not already used.',\n [FormDefinitionError.UniqueListItemId]:\n 'Each item in a list must have a unique ID. Change the item ID to one that is not already used.',\n [FormDefinitionError.UniqueListItemText]:\n 'Each item in a list must have unique text. Change the item text to one that is not already used.',\n [FormDefinitionError.UniqueListItemValue]:\n 'Each item in a list must have a unique value. Change the item value to one that is not already used.',\n [FormDefinitionError.RefPageCondition]:\n 'This page is referenced by a condition. Remove the condition before making changes to this page.',\n [FormDefinitionError.RefConditionComponentId]:\n 'Remove the condition before deleting this page',\n [FormDefinitionError.RefConditionListId]:\n 'A condition is using a list in this form. Remove the condition before making changes to the list.',\n [FormDefinitionError.RefConditionItemId]:\n 'A condition is using an item in this list. Remove the condition before making changes to the item.',\n [FormDefinitionError.RefConditionConditionId]:\n 'A condition is using another condition. Remove the reference before making changes.',\n [FormDefinitionError.RefPageComponentList]:\n 'A question on this page is using a list. Remove the reference before making changes to the list.',\n [FormDefinitionError.IncompatibleConditionComponentType]:\n 'You cannot change to this question type because this question is used in a condition. Remove the condition or select a different question type.',\n [FormDefinitionError.IncompatibleQuestionRegex]:\n 'The regex expression is invalid',\n [FormDefinitionError.Other]:\n 'There is a problem with the form definition. Check your changes and try again.'\n}\n"],"mappings":"AAGA,SACEA,mBAAmB,EACnBC,uBAAuB,EACvBC,oBAAoB;;AAItB;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GACtBC,UAAuD,IACpD;EACH,MAAMC,cAAc,GAAGC,KAAK,CAACC,OAAO,CAACH,UAAU,CAAC,GAAGA,UAAU,GAAG,CAACA,UAAU,CAAC;EAE5E,OAAO,UAAUI,MAAyB,EAAE;IAC1CA,MAAM,CAACC,OAAO,CAAEC,GAAG,IAAK;MACtB,IAAIA,GAAG,CAACC,KAAK,CAACC,SAAS,EAAE;QACvB;MACF;MAEA,KAAK,MAAMC,SAAS,IAAIR,cAAc,EAAE;QACtC,MAAMS,YAAY,GAAGZ,oBAAoB,CAACW,SAAS,CAAC;;QAEpD;QACA;QACA,MAAME,QAAQ,GACZ,OAAOL,GAAG,CAACC,KAAK,CAACK,GAAG,KAAK,QAAQ,GAAGN,GAAG,CAACC,KAAK,CAACM,IAAI,GAAGP,GAAG,CAACC,KAAK,CAACK,GAAG;QAEpE,IACEF,YAAY,CAACI,IAAI,KAAKjB,uBAAuB,CAACkB,MAAM,IACpDT,GAAG,CAAC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,CAAC5D,mBAAmB,CAAC6D,uBAAuB,GAC1C,qFAAqF;EACvF,CAAC7D,mBAAmB,CAAC8D,oBAAoB,GACvC,kGAAkG;EACpG,CAAC9D,mBAAmB,CAAC+D,kCAAkC,GACrD,iJAAiJ;EACnJ,CAAC/D,mBAAmB,CAACgE,yBAAyB,GAC5C,iCAAiC;EACnC,CAAChE,mBAAmB,CAACwC,KAAK,GACxB;AACJ,CAAC","ignoreList":[]}
|
|
@@ -9,4 +9,10 @@ export declare const checkErrors: (formErrors: FormDefinitionError | FormDefinit
|
|
|
9
9
|
* Get the custom errors from a form definition joi validation error
|
|
10
10
|
*/
|
|
11
11
|
export declare function getErrors(validationError: ValidationError | undefined): FormDefinitionErrorCause[];
|
|
12
|
+
/**
|
|
13
|
+
* Human-readable messages for each {@link FormDefinitionError} code, shared
|
|
14
|
+
* by services that surface definition-validation failures (designer editor
|
|
15
|
+
* flows, runner preview error pages).
|
|
16
|
+
*/
|
|
17
|
+
export declare const formErrorsToMessages: Record<FormDefinitionError, string>;
|
|
12
18
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/form/form-manager/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,KAAK,CAAA;AAE1C,OAAO,EACL,mBAAmB,EAGnB,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAA;AAEzC;;GAEG;AACH,eAAO,MAAM,WAAW,GACtB,YAAY,mBAAmB,GAAG,mBAAmB,EAAE,MAItC,QAAQ,GAAG,CAAC,WAAW,EAAE,sBAiD3C,CAAA;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,eAAe,EAAE,eAAe,GAAG,SAAS,GAC3C,wBAAwB,EAAE,CA8D5B"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/form/form-manager/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,KAAK,CAAA;AAE1C,OAAO,EACL,mBAAmB,EAGnB,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAA;AAEzC;;GAEG;AACH,eAAO,MAAM,WAAW,GACtB,YAAY,mBAAmB,GAAG,mBAAmB,EAAE,MAItC,QAAQ,GAAG,CAAC,WAAW,EAAE,sBAiD3C,CAAA;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,eAAe,EAAE,eAAe,GAAG,SAAS,GAC3C,wBAAwB,EAAE,CA8D5B;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAiDpE,CAAA"}
|
package/package.json
CHANGED
|
@@ -135,3 +135,59 @@ export function getErrors(
|
|
|
135
135
|
}) ?? []
|
|
136
136
|
)
|
|
137
137
|
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Human-readable messages for each {@link FormDefinitionError} code, shared
|
|
141
|
+
* by services that surface definition-validation failures (designer editor
|
|
142
|
+
* flows, runner preview error pages).
|
|
143
|
+
*/
|
|
144
|
+
export const formErrorsToMessages: Record<FormDefinitionError, string> = {
|
|
145
|
+
[FormDefinitionError.UniquePageId]:
|
|
146
|
+
'Each page must have a unique ID. Change the page ID to one that is not already used.',
|
|
147
|
+
[FormDefinitionError.UniquePagePath]:
|
|
148
|
+
'Each page must have a unique path. Change the page path to one that is not already used.',
|
|
149
|
+
[FormDefinitionError.UniquePageComponentId]:
|
|
150
|
+
'Each question on a page must have a unique ID. Change the question ID to one that is not already used.',
|
|
151
|
+
[FormDefinitionError.UniquePageComponentName]:
|
|
152
|
+
'Each question on a page must have a unique name. Change the question name to one that is not already used.',
|
|
153
|
+
[FormDefinitionError.UniqueSectionId]:
|
|
154
|
+
'Each section must have a unique ID. Change the section ID to one that is not already used.',
|
|
155
|
+
[FormDefinitionError.UniqueSectionName]:
|
|
156
|
+
'Each section must have a unique name. Change the section name to one that is not already used.',
|
|
157
|
+
[FormDefinitionError.UniqueSectionTitle]:
|
|
158
|
+
'Each section must have a unique title. Change the section title to one that is not already used.',
|
|
159
|
+
[FormDefinitionError.UniqueListId]:
|
|
160
|
+
'Each list must have a unique ID. Change the list ID to one that is not already used.',
|
|
161
|
+
[FormDefinitionError.UniqueListTitle]:
|
|
162
|
+
'Each list must have a unique title. Change the list title to one that is not already used.',
|
|
163
|
+
[FormDefinitionError.UniqueListName]:
|
|
164
|
+
'Each list must have a unique name. Change the list name to one that is not already used.',
|
|
165
|
+
[FormDefinitionError.UniqueConditionId]:
|
|
166
|
+
'Each condition must have a unique ID. Change the condition ID to one that is not already used.',
|
|
167
|
+
[FormDefinitionError.UniqueConditionDisplayName]:
|
|
168
|
+
'Each condition must have a unique display name. Change the display name to one that is not already used.',
|
|
169
|
+
[FormDefinitionError.UniqueListItemId]:
|
|
170
|
+
'Each item in a list must have a unique ID. Change the item ID to one that is not already used.',
|
|
171
|
+
[FormDefinitionError.UniqueListItemText]:
|
|
172
|
+
'Each item in a list must have unique text. Change the item text to one that is not already used.',
|
|
173
|
+
[FormDefinitionError.UniqueListItemValue]:
|
|
174
|
+
'Each item in a list must have a unique value. Change the item value to one that is not already used.',
|
|
175
|
+
[FormDefinitionError.RefPageCondition]:
|
|
176
|
+
'This page is referenced by a condition. Remove the condition before making changes to this page.',
|
|
177
|
+
[FormDefinitionError.RefConditionComponentId]:
|
|
178
|
+
'Remove the condition before deleting this page',
|
|
179
|
+
[FormDefinitionError.RefConditionListId]:
|
|
180
|
+
'A condition is using a list in this form. Remove the condition before making changes to the list.',
|
|
181
|
+
[FormDefinitionError.RefConditionItemId]:
|
|
182
|
+
'A condition is using an item in this list. Remove the condition before making changes to the item.',
|
|
183
|
+
[FormDefinitionError.RefConditionConditionId]:
|
|
184
|
+
'A condition is using another condition. Remove the reference before making changes.',
|
|
185
|
+
[FormDefinitionError.RefPageComponentList]:
|
|
186
|
+
'A question on this page is using a list. Remove the reference before making changes to the list.',
|
|
187
|
+
[FormDefinitionError.IncompatibleConditionComponentType]:
|
|
188
|
+
'You cannot change to this question type because this question is used in a condition. Remove the condition or select a different question type.',
|
|
189
|
+
[FormDefinitionError.IncompatibleQuestionRegex]:
|
|
190
|
+
'The regex expression is invalid',
|
|
191
|
+
[FormDefinitionError.Other]:
|
|
192
|
+
'There is a problem with the form definition. Check your changes and try again.'
|
|
193
|
+
}
|