> Portal Navigation:
>
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt
# ValidateSubmission
# Package: servicePlugins
# Namespace: FormSubmissionSpiExtensionService
# Method link: https://dev.wix.com/docs/api-reference/crm/forms/service-plugins/form-submissions-service-plugin/validate-submission.md
## Permission Scopes:
Manage Submissions: SCOPE.DC-FORMS.MANAGE-SUBMISSIONS
## Introduction
> **Note:** The Form Submission service plugin only works with the Wix Forms app. Call [GetAppInstance](https://dev.wix.com/docs/rest/api-reference/app-management/apps/app-instance/get-app-instance.md) to confirm that the app named `wix_forms` is installed on the site.
Validates a submission.
Validates a site visitor's form submission and returns any validation violations.
Site visitors can see the validation violations on their forms. For example, invalid fields are highlighted in red.
---
## REST API
### Schema
```
Method: validateSubmission
Description: > **Note:** The Form Submission service plugin only works with the Wix Forms app. Call [GetAppInstance](https://dev.wix.com/docs/rest/api-reference/app-management/apps/app-instance/get-app-instance.md) to confirm that the app named `wix_forms` is installed on the site.
Validates a submission.
Validates a site visitor's form submission and returns any validation violations.
Site visitors can see the validation violations on their forms. For example, invalid fields are highlighted in red.
URL: null
Method: POST
# Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
Required parameters: submission, actionType
Method parameters:
param name: actionType | type: ActionType | required: true
- enum:
UNKNOWN_ACTION - Unknown action type.
UPDATE - Update submission.
CREATE - Create submission.
- name: updateOptions | type: UpdateOptions | description: Data for updating an existing submission.
- name: currentSubmission | type: FormSubmission | description: Submission to update.
- name: formId | type: string | description: GUID of the form which the submission belongs to.
- name: status | type: SubmissionStatus | description: Status of the submission.
- enum:
- PENDING: A submission is created, but has not yet been recorded in the Wix Forms collection.
- CONFIRMED: A submission is recorded in the Wix Forms collection.
- PAYMENT_WAITING: A form submission requiring payment is created.
- PAYMENT_CANCELED: An order of a form submission is canceled.
- name: submissions | type: Map | description: Submission values where `key` is the form field and `value` is the data submitted for the given field.
- ONE-OF:
- name: nullValue | type: | description:
- name: numberValue | type: number | description:
- name: stringValue | type: string | description:
- name: boolValue | type: boolean | description:
- name: structValue | type: object | description:
- name: listValue | type: ListValue | description:
- name: values | type: array | description:
- name: createdDate | type: string | description: Date and time the form submission was created.
- name: seen | type: boolean | description: Whether a site owner marked a submission as "seen".
- name: extendedFields | type: ExtendedFields | description: Data extension object that holds users' and apps' fields.
- name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).
- name: orderDetails | type: OrderDetails | description: Order details.
Note: This object is only applicable when submitting a form in the Wix Payments app.
- name: contactId | type: string | description: Contact GUID of a site visitor who created the submission.
- name: accessRestriction | type: string | description: Authorized viewer GUID.
- name: tags | type: PublicTags | description: Tag GUIDs collections associated with the current entity.
- name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.
- name: tagIds | type: array | description: List of tag GUIDs
- name: appointmentDetails | type: AppointmentDetails | description: Appointment details. This object is only applicable when submitting a form that creates a booking appointment.
- name: staffMemberId | type: string | description: GUID of the staff member assigned to the appointment.
- name: staffMemberName | type: string | description: Name of the staff member assigned to the appointment.
param name: submission | type: FormSubmission | description: Form submission that was created or retrieved. | required: true
- name: formId | type: string | description: GUID of the form which the submission belongs to.
- name: status | type: SubmissionStatus | description: Status of the submission.
- name: submissions | type: Map | description: Submission values where `key` is the form field and `value` is the data submitted for the given field.
- name: createdDate | type: string | description: Date and time the form submission was created.
- name: seen | type: boolean | description: Whether a site owner marked a submission as "seen".
- name: extendedFields | type: ExtendedFields | description: Data extension object that holds users' and apps' fields.
- name: orderDetails | type: OrderDetails | description: Order details.
Note: This object is only applicable when submitting a form in the Wix Payments app.
- name: contactId | type: string | description: Contact GUID of a site visitor who created the submission.
- name: accessRestriction | type: string | description: Authorized viewer GUID.
- name: tags | type: PublicTags | description: Tag GUIDs collections associated with the current entity.
- name: appointmentDetails | type: AppointmentDetails | description: Appointment details. This object is only applicable when submitting a form that creates a booking appointment.
Return type: ValidateSubmissionResponse
- name: errors | type: array | description: List of validation errors.
If there are no validation errors, returns an empty array.
- ONE-OF:
- name: errorType | type: SubmissionErrorType | description: Predefined error type.
- enum:
- UNKNOWN_ERROR: Error is unknown or unsuitable for any of the options below.
- TYPE_ERROR: Type of submitted value is incorrect.
- REQUIRED_VALUE_ERROR: Value is required to be provided.
- UNKNOWN_VALUE_ERROR: Value contains additional properties not expected in schema.
- MAX_LENGTH_ERROR: Text value exceeds max length.
- MIN_LENGTH_ERROR: Text value does not reach min length.
- PATTERN_ERROR: Text value is not applicable for expected pattern.
- FORMAT_ERROR: Text value is not applicable for expected format.
- MAX_VALUE_ERROR: Number value is too big.
- MIN_VALUE_ERROR: Number value is too small.
- MULTIPLE_OF_VALUE_ERROR: Number value is not a multiple of expected number.
- MIN_ITEMS_ERROR: Array value has too many items.
- MAX_ITEMS_ERROR: Array value has not enough items.
- NOT_ALLOWED_VALUE_ERROR: Value is not in the list of allowed values.
- DISABLED_FORM_ERROR: Submitted form is disabled.
- name: customErrorMessage | type: string | description: Custom error message. The message is displayed instead of an error type.
- name: errorPath | type: string | description: Path indicating the source of the error, such as `form.fields.target`.
- name: params | type: object | description: Additional error parameters.
```
### Examples
### Validate submission
```curl
curl -X POST \
'http://www.wixapis.com/form-submission/v4/submissions/validate' \
-H 'Content-Type: application/json' \
-H 'Authorization: ' \
-d '{
"submission": {
"id": "e62e3011-55cf-4de3-a497-e097b52d86b7",
"formId": "e62e3011-55cf-4de3-a497-e097b52d86b8",
"namespace": "wix.form_app.form",
"status": "PENDING",
"submissions": {
"first_name": "J0hn",
"last_name": "Doe"
"fiend_list": ["Tom", "Sally", "Bob"]
},
"submitter": {
"memberId": "4b42fb49-8c77-4128-859c-8247756f68ef"
},
"seen": false,
"revision": 1,
"createdDate": "2019-10-30T17:22:10.299Z",
"updatedDate": "2019-10-30T17:22:10.299Z"
},
"actionType": "CREATE",
"createOptions": {}
}'
```
---
## JavaScript SDK
### Schema
```
Method: wixClientAdmin.servicePlugins.FormSubmissionSpiExtensionService.validateSubmission(request, metadata)
Description: > **Note:** The Form Submission service plugin only works with the Wix Forms app. Call [GetAppInstance](https://dev.wix.com/docs/rest/api-reference/app-management/apps/app-instance/get-app-instance.md) to confirm that the app named `wix_forms` is installed on the site.
Validates a submission.
Validates a site visitor's form submission and returns any validation violations.
Site visitors can see the validation violations on their forms. For example, invalid fields are highlighted in red.
Method parameters:
param name: metadata | type: Context | description: this message is not directly used by any service, it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform. e.g. SPIs, event-handlers, etc.. NOTE: this context object MUST be provided as the last argument in each Velo method signature. Example: ```typescript export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) { ... } ```
- name: requestId | type: string | description: A unique identifier of the request. You may print this GUID to your logs to help with future debugging and easier correlation with Wix's logs.
- name: currency | type: string | description: [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.
- name: identity | type: IdentificationData | description: An object that describes the identity that triggered this request.
- ONE-OF:
- name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site.
- name: memberId | type: string | description: GUID of a site visitor that has logged in to the site.
- name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.).
- name: appId | type: string | description: GUID of an app.
- name: languages | type: array | description: A string representing a language and region in the format of `"xx-XX"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash "-", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `"en-US"`.
- name: instanceId | type: string | description: The service provider app's instance GUID.
param name: request | type: ValidateSubmissionRequest
- name: updateOptions | type: UpdateOptions | description: Data for updating an existing submission.
- name: currentSubmission | type: FormSubmission | description: Submission to update.
- name: formId | type: string | description: GUID of the form which the submission belongs to.
- name: status | type: SubmissionStatus | description: Status of the submission.
- enum:
- PENDING: A submission is created, but has not yet been recorded in the Wix Forms collection.
- CONFIRMED: A submission is recorded in the Wix Forms collection.
- PAYMENT_WAITING: A form submission requiring payment is created.
- PAYMENT_CANCELED: An order of a form submission is canceled.
- name: submissions | type: Map | description: Submission values where `key` is the form field and `value` is the data submitted for the given field.
- ONE-OF:
- name: nullValue | type: | description:
- name: numberValue | type: number | description:
- name: stringValue | type: string | description:
- name: boolValue | type: boolean | description:
- name: structValue | type: object | description:
- name: listValue | type: ListValue | description:
- name: values | type: array | description:
- name: _createdDate | type: Date | description: Date and time the form submission was created.
- name: seen | type: boolean | description: Whether a site owner marked a submission as "seen".
- name: extendedFields | type: ExtendedFields | description: Data extension object that holds users' and apps' fields.
- name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).
- name: orderDetails | type: OrderDetails | description: Order details.
Note: This object is only applicable when submitting a form in the Wix Payments app.
- name: contactId | type: string | description: Contact GUID of a site visitor who created the submission.
- name: accessRestriction | type: string | description: Authorized viewer GUID.
- name: tags | type: PublicTags | description: Tag GUIDs collections associated with the current entity.
- name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.
- name: tagIds | type: array | description: List of tag GUIDs
- name: appointmentDetails | type: AppointmentDetails | description: Appointment details. This object is only applicable when submitting a form that creates a booking appointment.
- name: staffMemberId | type: string | description: GUID of the staff member assigned to the appointment.
- name: staffMemberName | type: string | description: Name of the staff member assigned to the appointment.
- name: submission | type: FormSubmission | description: Submission to validate.
- name: actionType | type: ActionType | description: Whether to create or update the submission.
- enum:
- UNKNOWN_ACTION: Unknown action type.
- UPDATE: Update submission.
- CREATE: Create submission.
Return type: PROMISE
- name: errors | type: array | description: List of validation errors.
If there are no validation errors, returns an empty array.
- ONE-OF:
- name: errorType | type: SubmissionErrorType | description: Predefined error type.
- enum:
- UNKNOWN_ERROR: Error is unknown or unsuitable for any of the options below.
- TYPE_ERROR: Type of submitted value is incorrect.
- REQUIRED_VALUE_ERROR: Value is required to be provided.
- UNKNOWN_VALUE_ERROR: Value contains additional properties not expected in schema.
- MAX_LENGTH_ERROR: Text value exceeds max length.
- MIN_LENGTH_ERROR: Text value does not reach min length.
- PATTERN_ERROR: Text value is not applicable for expected pattern.
- FORMAT_ERROR: Text value is not applicable for expected format.
- MAX_VALUE_ERROR: Number value is too big.
- MIN_VALUE_ERROR: Number value is too small.
- MULTIPLE_OF_VALUE_ERROR: Number value is not a multiple of expected number.
- MIN_ITEMS_ERROR: Array value has too many items.
- MAX_ITEMS_ERROR: Array value has not enough items.
- NOT_ALLOWED_VALUE_ERROR: Value is not in the list of allowed values.
- DISABLED_FORM_ERROR: Submitted form is disabled.
- name: customErrorMessage | type: string | description: Custom error message. The message is displayed instead of an error type.
- name: errorPath | type: string | description: Path indicating the source of the error, such as `form.fields.target`.
- name: params | type: object | description: Additional error parameters.
```
### Examples
### validateSubmission
```javascript
import { formSubmissions } from '@wix/forms/service-plugins';
async function validateSubmission(request,metadata) {
const response = await formSubmissions.validateSubmission(request,metadata);
};
```
### validateSubmission (with elevated permissions)
```javascript
import { formSubmissions } from '@wix/forms/service-plugins';
import { auth } from '@wix/essentials';
async function myValidateSubmissionMethod(request,metadata) {
const elevatedValidateSubmission = auth.elevate(formSubmissions.validateSubmission);
const response = await elevatedValidateSubmission(request,metadata);
}
```
### validateSubmission (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).
```javascript
import { createClient } from '@wix/sdk';
import { formSubmissions } from '@wix/forms/service-plugins';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed
const myWixClient = createClient ({
modules: { formSubmissions },
// Include the auth strategy and host as relevant
});
async function validateSubmission(request,metadata) {
const response = await myWixClient.formSubmissions.validateSubmission(request,metadata);
};
```
---