Skip to content

fix(turbosign): send required:false for optional signer fields - #85

Merged
amitsharma-turbodocx merged 3 commits into
mainfrom
feature/optional-signer-fields
Oct 5, 2026
Merged

amitsharma-turbodocx merged 3 commits into
mainfrom
feature/optional-signer-fields

Conversation

@nicolasiscoding

@nicolasiscoding nicolasiscoding commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Closes #86

Summary

TurboSign fields accept a required boolean. It defaults to true; required: false makes the field optional for the signer. This PR makes sure every SDK can send required: false and that it reaches the request body.

Go and PHP could not send it before:

  • go-sdk: Field.Required was a plain bool with omitempty, so false was always dropped. It is now *bool with omitempty: nil omits the key (required), turbodocx.BoolPtr(false) sends false, using the existing BoolPtr helper.
    • Source-breaking for Go callers who wrote Required: true. Change it to Required: turbodocx.BoolPtr(true), or drop it, since omitted already means required. In-repo examples and cmd/manual are updated.
  • php-sdk: Field::$required was bool $required = false and only sent when true. It is now ?bool $required = null and is sent whenever it is not null.
    • Behavior change: an explicit required: false used to be silently dropped and is now sent. On a signature or initial field, that now returns a 400 from the API instead of being ignored.

JS, Python, Java and Ruby already passed false through. Each of them gets a payload test in this PR, plus doc updates.

API rules

  • Omitting required means the field is required.
  • required: false on a signature or initial field is rejected with 400 OptionalNotSupported. This rule is documented on the field in each SDK.
  • A non-boolean required is rejected with 400 InvalidFieldRequired.
  • A recipient whose only editable fields are optional or read-only is rejected with 400 NoEditableFieldsForRecipient.

The SDKs do not validate these rules client-side. A rejection is surfaced as a 400 ValidationError.

Tests

Every SDK has a new test with three fields (required: true, required: false, and no required) that checks the serialized fields part: true, false, and the key absent. JS, Python, Go, Java and Ruby check the request captured by their mocked HTTP layer. PHP has no HTTP-mocked TurboSign test, so its test checks fields encoded the same way TurboSign builds it (json_encode of each Field::toArray()).

SDK Change Before fix Command Result
js-sdk verified + docs passed (pass-through) npm run build && npx jest 336 passed
go-sdk fixed build failed (*bool vs bool) go test ./..., go vet -tags manual ./cmd/manual/ ok
php-sdk fixed failed (required key missing) composer test, composer phpstan, composer cs-fix -- --dry-run 369 tests OK, phpstan no errors, cs-fixer clean
java-sdk verified + docs passed (Gson keeps Boolean.FALSE, drops null) mvn test -B 329 tests, 0 failures
py-sdk verified + docs passed (pass-through) pytest 346 passed
ruby-sdk verified + docs passed (pass-through) bundle exec rspec 330 examples, 0 failures

Note: go-sdk/examples/turbosign_advanced.go (//go:build ignore) already fails go vet on main because of an unrelated recipient.Status reference. This PR does not touch that line.

No version bump; this follows the repo convention of bumping in a separate lockstep release. Because of the Go change, that release should be a minor bump.

🤖 Generated with Claude Code

Nicolas Fry added 2 commits October 4, 2026 11:18
TurboSign fields accept `required` (default true). Setting it to false makes
the field optional for the signer. Go and PHP could not send false:

- go-sdk: Field.Required is now *bool with omitempty. nil omits the key
  (required), BoolPtr(false) sends false. Source-breaking for callers that
  wrote `Required: true`; use `Required: turbodocx.BoolPtr(true)`.
- php-sdk: Field::$required is now ?bool (default null) and is sent whenever
  it is not null, so an explicit false reaches the API.

JS, Python, Java and Ruby already passed false through; each gets a request
payload test plus doc updates. Signature and initial fields are always
required (the API rejects required:false on them with a 400).
Adds OptionalNotSupported, InvalidFieldRequired and NoEditableFieldsForRecipient
to each SDK's error-code table, and a cross-SDK parity rule for the field
`required` flag: keep unset, true and false apart and never send it on a
truthiness check.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@amitsharma-turbodocx
amitsharma-turbodocx merged commit 899e4aa into main Oct 5, 2026
12 checks passed
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.

fix(turbosign): send required:false for optional signer fields

2 participants