Skip to content

docs: omit implementation details from hooks reference#1675

Merged
serikjensen merged 3 commits intomainfrom
docs/hooks-omit-fields-metadata
May 6, 2026
Merged

docs: omit implementation details from hooks reference#1675
serikjensen merged 3 commits intomainfrom
docs/hooks-omit-fields-metadata

Conversation

@serikjensen
Copy link
Copy Markdown
Member

Summary

Tightens the hook reference docs to focus on what partners need to build forms, removing implementation-detail leaks that don't help integrators and that previously could mislead readers into wiring forms in non-recommended ways.

Changes

  • Removed the Advanced: Fields Metadata section from hooks.md so partners aren't steered toward consuming fieldsMetadata directly. Field components consume metadata internally; the recommended path is Fields (with FieldComponent for UI overrides).
  • Reworded the Fields.Ssn section to describe the masked placeholder + auto-waived REQUIRED rule behaviorally instead of via fieldsMetadata.ssn.hasRedactedValue.
  • Replaced internal symbols with behavioral descriptions: NAME_REGEX (Employee Details), FLSA_OVERTIME_SALARY_LIMIT (Compensation), rev_2020_w4 (Federal Taxes).
  • Stripped schema-builder vocabulary ('never' / 'always' / "predicate", "schema declares/enforces") from Pay Schedule, Compensation, and hooks.md in favor of partner-facing language.
  • Dropped the internal Rule column from the Compensation required-fields table; the remaining columns convey the same partner-relevant info.
  • Removed raw HTTP endpoint paths (e.g. GET /v1/work_addresses/{work_address_uuid}, POST) from Work Address mode descriptions in favor of mode-only language.

What was intentionally preserved:

  • fieldsMetadata in return-type signatures and the SignEmployeeFormFieldsMetadata row in the Exported Types table — they accurately describe the public return shape without prescribing direct consumption.
  • react-hook-form / Zod / UseFormReturn references — partner-relevant framework context, especially for the Advanced: Hook Form Internals escape hatch.
  • Cross-references to other public hooks (e.g. useCurrentWorkAddressForm, useWorkAddressManagement).

Testing

  • Docs-only change; no code touched.
  • Re-grepped `docs/hooks/` to confirm no remaining `NAME_REGEX`, `FLSA_OVERTIME_SALARY_LIMIT`, `rev_2020_w4`, `/v1/`, `'never'`/`'always'` requiredness, or "predicate rule" references outside legitimate framework/behavioral usage.
  • Visual review of each modified `docs/hooks/*.md` file confirmed updates read cleanly.

Made with Cursor

@serikjensen serikjensen marked this pull request as ready for review May 5, 2026 21:18
Comment thread docs/hooks/hooks.md Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the semi-colon before the JSX required? It always looks a little odd to my eye

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

Comment thread docs/hooks/hooks.md
<Fields.Email label="Email" formHookResult={employeeDetails} />
```

Each field reads metadata, form control, and error state directly from the prop. This is the most flexible approach — fields can be placed anywhere in your component tree and interleaved freely with fields from other hooks.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding an example of two forms? I think I finally pictured it after reading the pros/cons of each approach but actually showing it in code might help with comprehension

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup!

Comment thread docs/hooks/hooks.md Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not have any default validation messages for hooks?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not currently! but this is a good catch, the test here is incorrect. It displays with "REQUIRED"

Going to correct

i'd be open to providing default validation messages, we'd just want to be sure that we aren't putting translations in hooks and we'd also want to be sure that we are providing the translations in the downstream component where the hook is used. I figured that might be easy to miss if the validation errors appeared to be rendering properly

serikjensen and others added 2 commits May 6, 2026 16:41
Tightens the hook reference docs to focus on what partners need to build
forms, removing implementation-detail leaks that don't help integrators
and that previously could mislead readers into wiring forms in
non-recommended ways.

- Removed the Advanced: Fields Metadata section from hooks.md so
  partners aren't steered toward consuming fieldsMetadata directly.
- Reworded the Fields.Ssn section to describe the masked placeholder +
  auto-waived REQUIRED rule behaviorally rather than via the
  fieldsMetadata.ssn.hasRedactedValue flag.
- Replaced internal symbols with behavioral descriptions: NAME_REGEX
  (Employee Details), FLSA_OVERTIME_SALARY_LIMIT (Compensation),
  rev_2020_w4 (Federal Taxes).
- Stripped schema-builder vocabulary ('never'/'always'/predicate,
  "schema declares/enforces") from Pay Schedule, Compensation, and
  hooks.md.
- Dropped the internal Rule column from the Compensation required-fields
  table.
- Removed raw HTTP endpoint paths from Work Address mode descriptions
  in favor of mode-only language.

fieldsMetadata is preserved in return-type signatures and the
SignEmployeeFormFieldsMetadata Exported Types entry since those
accurately describe the public return shape without prescribing direct
consumption.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Replace leading-`;` JSX snippets with proper function/expression
  contexts (Option B SDKFormProvider example, FieldComponent example)
  so the markdown reads cleanly without ASI defenders.
- Add a side-by-side two-hook example after the Choosing an Approach
  table so readers can picture interleaved (formHookResult) vs grouped
  (SDKFormProvider) layouts before scrolling to Composing Multiple Hooks.

Co-authored-by: Cursor <cursoragent@cursor.com>
@serikjensen serikjensen force-pushed the docs/hooks-omit-fields-metadata branch from 7a72698 to 80cca43 Compare May 6, 2026 22:43
When validationMessages is omitted, the field doesn't go quiet — it
displays the raw schema error code (REQUIRED, INVALID_EMAIL, etc.)
as the error message. Update the blurb to describe that fallback
accurately and steer partners toward always supplying messages.

Co-authored-by: Cursor <cursoragent@cursor.com>
@serikjensen serikjensen enabled auto-merge (squash) May 6, 2026 22:48
@serikjensen serikjensen merged commit e0b8823 into main May 6, 2026
19 checks passed
@serikjensen serikjensen deleted the docs/hooks-omit-fields-metadata branch May 6, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants