submitForm reads forms.consentFieldName from ipalKit options
The option was typed but never read. An explicit argument still wins. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
38c1d9215e
commit
4585e0fc69
@@ -10,7 +10,8 @@ import { validateSubmission } from './validateSubmission.js'
|
||||
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'.
|
||||
* for the submission to succeed (enforced server-side). Defaults to
|
||||
* ipalKit({ forms: { consentFieldName } }), then 'consent'.
|
||||
*/
|
||||
consentFieldName?: string
|
||||
/** Submitted field data — shape matches the form's fields. */
|
||||
@@ -129,7 +130,10 @@ export async function submitForm({
|
||||
|
||||
// 3. Validate against the form's schema. A public endpoint can't trust the
|
||||
// shape of `data` — drop unknown keys, enforce required, cap length.
|
||||
const validation = await validateSubmission(payload, formId, data, consentFieldName)
|
||||
// Explicit argument → ipalKit({ forms: { consentFieldName } }) → 'consent'.
|
||||
const configured = (payload.config?.custom as { ipal?: { consentFieldName?: unknown } } | undefined)?.ipal?.consentFieldName
|
||||
const consentField = consentFieldName ?? (typeof configured === 'string' && configured ? configured : undefined)
|
||||
const validation = await validateSubmission(payload, formId, data, consentField)
|
||||
if (!validation.ok) {
|
||||
if (validation.reason === 'not_found') {
|
||||
return { reason: 'not_found', success: false }
|
||||
|
||||
Reference in New Issue
Block a user