sveltekit-superforms
Advanced tools
Changelog
[2.6.2] - 2024-02-25
typeof
type, which prevented multi-type union detection.FormPath
and FormPathLeaves
didn't narrow the types correctly for Date
, Set
and File
.stringProxy
didn't accept FormPathLeaves
as path.Schema
type, for any supported validation schema.Changelog
[2.6.1] - 2024-02-24
FormPath
and its relatives, to filter the paths based on a specific type, like FormPathLeaves<T, Date>
.FieldProxy
, FormFieldProxy
and ArrayProxy
.invalidateAll
option 'force'
, to always use the load function form data, instead of the one returned from the form action. Useful when updating the form data partially, to ensure that the data is refreshed from the server (a "pessimistic" update compared to the default, which is optimistic). Setting this also bases the reset
function on the latest load function data returned for the form.defaults
didn't infer the input type, and didn't generate correct SuperValidated
data, making superForm
confused. Also fixed type signature and removed the jsonSchema
option that wasn't applicable.goto
in events didn't work when the target page redirected.FormPath
and FormPathLeaves
didn't handle fields with type unknown
and any
.Changelog
[2.5.0] - 2024-02-21
get
and set
accessor for onChange
.submit
method for superForm
, a convenience instead of using requestSubmit. Requires use:enhance
or that a HTMLElement
inside the form (or the form itself) is passed as an argument.ChangeEvent
, which should be of the inferred schema type.onChange.paths
wasn't strongly typed to FormPath
.superForm
, so it wasn't possible to update it when using reset
.FormOptions
type required a type parameter that should've been defaulted to Record<string, unknown>
.Changelog
[2.4.0] - 2024-02-20
config
option to Valibot adapter, for the SchemaConfig type.Changelog
[2.3.0] - 2024-02-18
undefined
when posting invalid data.onSubmit.jsonData
, to override what's being submitted, when dataType is set to 'json'
and validation succeeds for $form
.onSubmit.validators
, to temporarily override validators for the current submission.Changelog
[2.2.1] - 2024-02-16
focusOnError
option to SuperForm.validateForm
type (it was only in the implementation).$posted
was reset by mistake to false
after posting, when resetForm
option was true.Changelog
[2.2.0] - 2024-02-15
focusOnError
option to validateForm
, default true
.validateForm({ update: true })
.$errors
primarily, didn't handle nested data properly.message
, it can now be used to specify the message type.Changelog
[2.1.0] - 2024-02-12
undefined
when using dataType: 'json'
.Changelog
[2.0.0] - 2024-02-11
superForm.fields
was a rarely used and lesser version of formFieldProxy
, switch to that instead.fields
options when setting tainted status.message
parameter in onError
event, use $message
directly instead.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.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
.superformClient
adapter. The input for the validator functions can now be undefined
.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
.required
in their constraints anymore.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
.defaultValidators
option, 'clear'
can now be set directly on validators
instead.emptyIfZero
setting from numberProxy
and intProxy
.validate()
called with no arguments is renamed to validateForm()
and can take two extra options, update
and schema
.dataType: 'json'
set.superForm.isTainted(path?)
and superForm.isTainted($tainted)
for better tainted fields check.withFiles
when returning in form actions: return withFiles({ form })
.File
and FileList
.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.onChange
event to superForm
, that returns a list of modified fields whenever $form
is updated.'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
.