added validation for forms, sensitive text fields have been masked
This commit is contained in:
Vendored
+12
-1
@@ -1,6 +1,11 @@
|
||||
import 'server-only';
|
||||
import type { BasePayload } from 'payload';
|
||||
export type SubmitFormArgs = {
|
||||
/**
|
||||
* Name of the GDPR consent checkbox. A field with this name must be checked
|
||||
* for the submission to succeed (enforced server-side). Defaults to 'consent'.
|
||||
*/
|
||||
consentFieldName?: string;
|
||||
/** Submitted field data — shape matches the form's fields. */
|
||||
data: Record<string, unknown>;
|
||||
/** Form-builder form ID this submission belongs to. */
|
||||
@@ -30,6 +35,7 @@ export type SubmitFormArgs = {
|
||||
* `field` and `kind` narrow it down when a specific field is
|
||||
* at fault (absent for whole-payload problems like unknown keys)
|
||||
* - `not_found` — no form with this id
|
||||
* - `consent` — a required GDPR consent checkbox was left unchecked
|
||||
* - `error` — persistence failed unexpectedly
|
||||
*/
|
||||
export type SubmitFailure = {
|
||||
@@ -39,6 +45,11 @@ export type SubmitFailure = {
|
||||
kind?: 'required' | 'too_long' | 'unknown_fields';
|
||||
reason: 'validation';
|
||||
success: false;
|
||||
} | {
|
||||
field?: string;
|
||||
/** A GDPR consent field existed on the form but wasn't checked. */
|
||||
reason: 'consent';
|
||||
success: false;
|
||||
} | {
|
||||
reason: 'error';
|
||||
success: false;
|
||||
@@ -69,4 +80,4 @@ export type SubmitFormResult = {
|
||||
*
|
||||
* server-only: touches the Turnstile secret.
|
||||
*/
|
||||
export declare function submitForm({ data, formId, ip, maxPerMinute, payload, turnstileToken, }: SubmitFormArgs): Promise<SubmitFormResult>;
|
||||
export declare function submitForm({ consentFieldName, data, formId, ip, maxPerMinute, payload, turnstileToken, }: SubmitFormArgs): Promise<SubmitFormResult>;
|
||||
|
||||
Reference in New Issue
Block a user