fix: validation bugs, simpler public types, and example cleanup - #22
Merged
Conversation
The second OR branch re-checked `path === undefined` instead of `message === undefined`, so an object with a non-string message and an undefined path was wrongly accepted as a ValidationError. Add a dedicated test suite for the guard covering the regression. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
check() validated against the schema captured at hook init, ignoring setSchema(). Every other validation method already uses schemaRef.current, so check() now does too, making its behaviour consistent. Add a regression test asserting check() uses the updated schema. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
removeAll computed `paths` (pathsToValidate + live-validated fields) but then used only `pathsToValidate` for error teardown and validation, so fields with active live-validation were skipped — inconsistent with writeAll, which uses `paths`. Align removeAll to writeAll. Add a regression test asserting live-validated fields are re-validated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rewrite src/types/index.ts for readability and correctness, and export the useful types from the package entry point so consumers can type their own code. - Collapse the redundant base types (FormbitRecord, Form, InitialValues) into a single FormbitValues type used everywhere. - Remove the field `isDirty` from PrivateValidateForm options: it was destructured and discarded, i.e. dead. - Simplify SubmitSuccessCallback's writer type to FormState<Omit<Values, '__metadata'>>, matching what submitForm actually passes at runtime. - Reorganise the file into clear sections and tighten the doc comments. - Re-export FormbitObject, the method/callback/options types and the yup re-exports from the package root. BREAKING CHANGE: the deprecated type aliases are removed (Object, Writer, SuccessCheckCallback, ErrorCheckCallback, ErrorFn, IsFormValid, IsFormInvalid, ClearIsDirty, ResetForm, LiveValidationFn, IsDirty), together with the internal base types FormbitRecord, Form and InitialValues. Use FormbitValues instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`FormData` shadows the browser's global FormData type, which is confusing
in an example meant to teach. Rename it to FormValues across every example
and switch the imports to type-only (`import type` / `import { type ... }`)
for consistency.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The addable-fields example was writing and validating the wrong paths, so
editing an existing friend never worked:
- write targeted `friends[i].key` for both name and surname (→ `.name` / `.surname`)
- validate/error targeted the non-existent `headers[i]` path (→ `friends[i]`)
- the mapped <Friend> had no React key, and `friends?.[i].name` could throw
Also fix f-remove-all, which mixed up `age` and `email`: the loading skeleton
showed an "Email" field with an "Age" placeholder, and it initialized an `email`
value the schema doesn't have — both now consistently use `age`.
Alignment across the examples:
- pass `initialValues={{}}` explicitly on every Provider
- use the single `FormValues` type in e-multiple-steps instead of two divergent
local `Context` types
- fix copy/pasted Cypress describe/it names
- document why the fake GET randomly fails (and that it makes edit-like flaky)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The three multi-step files were indented with 4 spaces per level (and an extra offset) instead of the project's 2-space style; d-edit-like's provider had a stray offset too. ESLint doesn't enforce JSX indentation here and there is no Prettier, so this went unnoticed. Reindent to 2 spaces and drop the single-child fragments in StepOne/StepTwo. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
package.json and yarn.lock declared 2.13.1 but node_modules actually had a newer version installed, so the examples rendered with styles that didn't match the pinned version. Align all three on 2.19.5, which is the version that carries the corrected button :focus styling (box-shadow instead of the old primary color/border on focus). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add react/jsx-indent and react/jsx-indent-props (2 spaces) to both the root and example eslint configs, so the JSX indentation issues we hit can no longer slip through. Reindent the few files that weren't conforming.
Rinomina il type parameter generico da Values a T in tutte le firme dei tipi e nell'implementazione. Convenzione più concisa in stile Java; FormbitValues resta invariato. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
rivamarco
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cosa
Branch che raccoglie tre filoni di lavoro: correzioni a bug di validazione,
una semplificazione (breaking) dei tipi TypeScript pubblici, e allineamento
degli esempi.
Bugfix di validazione
isValidationError: corretto il check sul messaggio nel type guard.check(): ora rispetta lo schema impostato viasetSchema(prima usavasempre lo schema iniziale).
removeAll: ora ri-valida i campi in live-validation dopo la rimozione.Tipi pubblici (⚠️ breaking)
feat!: pulizia e semplificazione dei tipi TypeScript pubblici.Values→Tin tutte le firme(
FormbitValuesresta invariato). Convenzione più concisa e leggibile.Esempi & manutenzione
addable-fields(scriveva/validava path sbagliati: editare unfriend esistente non funzionava) e
f-remove-all(confondevaage/email).FormData→FormValuesnegli esempi (evita lo shadowingdel global
FormDatadel browser); import spostati a type-only.initialValues={{}}esplicito), tipi e nomi dei testCypress; documentato perché la fake GET fallisce a random.
radicalbit-design-system→ 2.19.5 (allineati package.json e yarn.lockal pacchetto realmente installato).
dei file non conformi.