Skip to content

Releases: ciscoheat/sveltekit-superforms

v2.1.0

13 Feb 14:05
Compare
Choose a tag to compare

Migration guide: https://superforms.rocks/migration-v2
More detailed list of what's new: https://superforms.rocks/whats-new-v2

Fixed

  • Enums can now be a required field again, as they don't need an explicit default value anymore. If no explicit default value exists, the first enum value will be used.
  • Empty arrays were set to undefined when using dataType: 'json'.

v2.0.0

11 Feb 16:31
Compare
Choose a tag to compare

Migration guide: https://superforms.rocks/migration-v2
More detailed list of what's new: https://superforms.rocks/whats-new-v2

Removed

  • superForm.fields was a rarely used and lesser version of formFieldProxy, switch to that instead.
  • Removed fields options when setting tainted status.
  • Remvoed message parameter in onError event, use $message directly instead.

Changed

  • Adapters required for validation! Import from sveltekit-superforms/adapters and use superValidate(zod(schema)) instead of superValidate(schema). If type parameters are used, it must now be wrapped with Infer for schemas.
  • Default superForm options now follow SvelteKit more closely: resetForm: true and taintedMessage: false are default now. Add define: { SUPERFORMS_LEGACY: true } in vite.config.ts to keep the old behavior.
  • superValidateSync is renamed to defaults. It returns default values for the schema, and does no validation anymore. Use +page.ts if initial validation is required, as described on the SPA page.
  • arrayProxy: fieldErrors renamed to valueErrors.
  • Enums must have an explicit default value in the schema.
  • Numeric enums cannot be parsed with their string values anymore.
  • Superform validator functions, previously just an object with functions, requires the superformClient adapter. The input for the validator functions can now be undefined.
  • If superValidate is called with just the schema, the default values aren't validated (i.e. no side-effects for default values) unless errors is set to true.
  • Properties with default values don't have required in their constraints anymore.
  • Form id cannot be undefined anymore, must be string. (Set automatically by default now).
  • flashMessage.onError.message option in superForm renamed to flashMessage.onError.flashMessage.
  • constraints are now optional in the SuperValidated type, and are returned only when loading data, not posting. This is only relevant if you modify constraints before calling superForm.
  • Removed the defaultValidators option, 'clear' can now be set directly on validators instead.
  • Removed the emptyIfZero setting from numberProxy and intProxy.
  • validate() called with no arguments is renamed to validateForm() and can take two extra options, update and schema.

Added

  • Support for unions in schemas. A union must have an explicit default value, and multi-type unions can only be used with dataType: 'json' set.
  • Added superForm.isTainted(path?) and superForm.isTainted($tainted) for better tainted fields check.
  • File upload support! Use withFiles when returning in form actions: return withFiles({ form }).
  • SuperDebug now displays File and FileList.
  • All proxies can now take the whole superForm object (previously only the form store was accepted), with an extra taint option to prevent tainting.
  • taintedMessage can now be an async function resolving to true if navigation should be allowed, despite the form being tainted.
  • Added an onChange event to superForm, that returns a list of modified fields whenever $form is updated.
  • Added 'zero' to the empty option of numberProxy and intProxy. Also added initiallyEmptyIfZero option, to show the placeholder for numeric inputs, which would otherwise display 0.

v1.13.4

20 Jan 09:23
Compare
Choose a tag to compare

Fixed

  • Error set on the server with setError didn't show up when submitting the form with an enter keypress.

v1.13.3

14 Jan 14:42
Compare
Choose a tag to compare

Fixed

  • Using full version of klona to address a cloning issue. (#312)
  • Nullable nested objects couldn't be reassigned with $form when null. (#311)

v1.13.2

07 Jan 12:45
Compare
Choose a tag to compare

Fixed

  • The timers didn't reset after navigation in certain cases.
  • Exported FormPathType in top export.

v1.13.1

22 Dec 05:20
Compare
Choose a tag to compare

Added

  • strict option added to superValidate, to ensure that all schema fields exist. In the default non-strict mode, non-existing fields are automatically using their default value. (#295, thanks to 21RISK for the PR)

Fixed

  • Upgraded to faster cloning library (klona)

v1.12.0

14 Dec 22:15
Compare
Choose a tag to compare

Added

  • Support for Zod branded types in schemas. (#286)
  • Peer dependencies updated to support SvelteKit 2. (#299)

Fixed

  • Tainted fields were set to undefined when not needed, unwantingly triggering client-side validation.
  • Schema transformations now updates the form data depending on input type. Checkboxes, radio buttons and selects updates the data immediately. Other inputs waits until blurred. (#298)
  • In SPA mode, the novalidate attribute now only disables the browser validation constraints, not the entire client-side validation. (#297)
  • Errors thrown in hooks are now handled properly by onError. Status will always be 500 though. (#292)

v1.11.0

28 Nov 06:29
Compare
Choose a tag to compare

Added

  • A fieldErrors store is added to arrayProxy, so field errors (for items in the array, not the array itself) can be accessed.

Fixed

  • When cancelling a request, timers were cancelled too early in SPA mode and when client-side validation failed.
  • Proxies didn't set or update a nested path unless it previously existed.
  • When the taint option was set to false or untaint-all, client-side validation was prevented.
  • The novalidate and formnovalidate attributes on forms and buttons weren't respected. (#287)

v1.10.2

14 Nov 15:41
Compare
Choose a tag to compare

Fixed

  • Timers weren't starting until after onSubmit, which allowed multiple form submissions on longer async operations. (#284)
  • Fixed constraints on fields that starts with a number. (#285)

v1.10.1

07 Nov 15:49
Compare
Choose a tag to compare

Added

  • Added arrayProxy, for proxying arrays and their errors in the form data. Example available on Stackblitz.
  • Added FormPathArrays type, enumerating all arrays in an object as string accessors. Used to access arrayProxy in a type-safe manner.
  • formFieldProxy now has a taint option, in case a modification should not taint the form.