Headlines: Added, Changed, Deprecated, Removed, Fixed, Security
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Valibot updated to require
1.0.0-beta.3
(hoping for a stable release soon). - Arktype updated to require
2.0.0-rc.23
(hoping for a stable release soon).
- Support for Vine 2.0.
- customRequest didn't cancel when client-side validation failed.
- New validation library: Effect!
@typeschema/class-validator
version bump to^0.3.0
.
- Exported
ClientValidationAdapter
fromsveltekit-superforms/adapters
.
- Result can now be modified in onError, for setting a status code for example.
- Status codes above 400 but below 500 were not applied to the page status when the result was modified in
onUpdate
.
- Arktype updated to require
2.0.0-rc.8
, fixing some types (last update before 2.0).
- The
failStatus
and SPA action form (string
) options of single page application mode are now deprecated.failStatus
is rarely used, and SPA action form can be created just by setting invalidateAll and applyAction tofalse
. See this example for details.
- Exceptions thrown in the
onSubmit
,onResult
andonUpdate
events will now be caught and sent toonError
, if it exists.
- Updating the same variable to the same value prevented the onChange event from being triggered.
- Factorized SuperDebug clipboard script
- New validation library: class-validator!
- Exported
SuperFormData
andSuperFormErrors
types for superForm. - Exported
ZodObjectType
,ZodObjectTypes
andZodValidation
types for the Zod adapter. - customRequest can now handle an
ActionResult
as well, for better error handling.
- Using setError in the load function and navigating to the same page client-side removed the errors.
posted
is deprecated, due to inconsistencies between server and client validation, and SPA mode. It will be removed in v3. Use a status message or return your own data in the form action to handle form post status.
descriptionAsErrors
option for the JSON Schema validator, so you can specify error messages directly in the schema with thedescription
field.
- File uploads required extra configuration for the valibot adapter, now it works directly.
- Events added in
enhance
weren't cleaned up when the form was destroyed. Note that this could be deprecated in a future version. It's advised to use events only when callingsuperForm
, not withenhance
.
- Arktype updated to require
2.0.0-beta.0
, which should fix some typing issues with the adapter.
- New validation library: Superstruct!
customRequest
added to the onSubmit options, that lets you use a custom fetch or XMLHttpRequest when submitting the form. Very useful for progress bars when uploading large files.
- Type inference for validation errors didn't include
_errors
for all objects, only for arrays.
- Valibot minimum dependency is now
>=0.33.0
to fix a type issue. Please follow the migration guide to update your Valibot schemas if your version is below v0.31.0.
- Valibot updated to
0.31.0
, which ends support for any version below that. Please follow the migration guide to update your Valibot schemas.
- Inlined the SuperDebug css, to prevent it from being automatically bundled due to it being a default import.
- The customValidity option now handles object errors, and can refer to any part of the schema.
- Arktype code wasn't excluded from bundle due to not being dynamically loaded.
errorMap
option for the Zod adapter, for simplified error handling in localization. (Zod docs)
isTainted
now works with undefined values in the$tainted
store.- Fixed default properties for Record in schemas.
FormPath
now extends only basic objects and arrays, avoiding issues with classes, all built-in objects likeFile
andDate
, and special "branded" types that validation libraries are using. Thanks to Matt DeKok for this fix!- SuperDebug always renders left-to-right now.
- Discriminated unions for the form itself weren't including the union keys for the schema, when parsing the form data.
devalue
updated to^5.0.0
to handle invalid dates.
- Support for "raw" JSON Schema validation with the new schemasafe adapter. Thanks to sukeshpabolu for the initial work on this!
- Errors weren't reset properly when the form was resetted, causing client-side validation to behave like the field was tainted.
- The Zod adapter didn't handle reused schemas ($ref) properly.
- The "GET to POST" modification for
use:enhance
was only intended for SPA mode to fully support progressive enhancement, so it now properly checks for that before adding the missingmethod="POST"
attribute on the form. - The tainted message didn't trigger on page refresh or closing a tab in the browser.
FormPathLeaves
caused a memory leak when usingsvelte-package
.
- SuperDebug support for
Map
andSet
. submit
method now falls back to submit, if no support for requestSubmit in browser.isTainted
now handles the type of$tainted
in generic components.id
option for superForm (not superValidate) wasn't used in multiple form scenarios.
- Fixed
FormResult
type that can be used inonUpdate
, it didn't filter out SuperValidated.
- SPA action form now supports form elements as well, by adding its
use:enhance
on all related forms.
- Fixed type inference for
FormPath
with nested arrays. Error output improved as well. - If method is "GET" or doesn't exist on an enhanced form, it's now automatically set to "POST".
- The
ActionResult
for success or failure is now added to theonUpdate
event in theresult
property. Can be used to more easily access theActionData
. - Added a
fail
function, works the same as the SvelteKit fail, but removes files and setsform.valid
tofalse
. options.config
added to the Zod adapter, so the JSON Schema generation can be customized.
- Snapshots couldn't handle files. They are now reverted to their default value when captured and restored in a snapshot, including the tainted state for these fields.
- The clearOnSubmit option didn't clear the errors when supposed to. To avoid a breaking change, the default option for clearOnSubmit is now
message
, noterrors-and-message
, as it didn't work anyway.
- the
event.result.error
signature in onError was incorrect, it doesn't always matchApp.Error
. It is now a union betweenApp.Error
, The built-in JSError
class, and the default App.Error signature{ message: string }
.
fileProxy
,filesProxy
,fileFieldProxy
andfilesFieldProxy
, soFile
objects can be used withbind:files
on the input field. See file uploads for examples.- Exported
FormPathLeavesWithErrors
, for thesetError
function.
- Support for
instance
andspecial
validators for Valibot, which now enables File validation for Valibot! taintedMessage
didn't always work when navigating with the History API.tainted
didn't untaint automatically when using arrays.- Client-side validation triggered for incorrect fields when starting with the same name.
- "SPA action mode", the
SPA
option can now take a string, corresponding to a form action, and it will post there, even without a html form on the page. Especially useful for debounced server checks like available usernames.
- Fixed types for constraints, tainted and errors when using intersections and unions in schemas.
- Fixed SuperDebug collapsed height by preventing global css leak.
- Redirect in SPA mode cancelled normal redirects, preventing applyAction.
- Default objects sent to
superForm
returned a form with an empty id, causing collisions, it is now a random string. customValidity
didn't clear without client-side validators.
- Clipboard copy button for SuperDebug. Also fixed height when collapsed without label.
- Storybook fix for missing
page
store.
- Support for object unions, with implicit default values.
- Experimental storybook support.
- It wasn't possible to directly assign
undefined
to a field in the$errors
store. - Intersections in Zod schemas weren't handled properly.
- It wasn't possible to change the reference to the result in
onResult
.
newState
option forreset
, to set a new state for future resets. Can be used instead of thedata
option.
- Empty file entries didn't return
null
for nullable schema fields. Ensure that all required file fields aren't set to nullable. - Allowed
string
index in$errors
and$tainted
. submit
can now be passed directly to event handlers.- Updated to latest
valibot-json-schema
, with support for enum_, amongst others. - Zod adapter now supports
ZodType
.
- Schema literals weren't treated as their
typeof
type, which prevented multi-type union detection. FormPath
andFormPathLeaves
didn't narrow the types correctly forDate
,Set
andFile
.stringProxy
didn't acceptFormPathLeaves
as path.- Fixed removal of uploads for empty files (as is the default for empty file inputs), they are now ignored.
- Exported
Schema
type, for any supported validation schema.
- Type narrowing for
FormPath
and its relatives, to filter the paths based on a specific type, likeFormPathLeaves<T, Date>
. - Proxy types:
FieldProxy
,FormFieldProxy
andArrayProxy
. - Added
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 thereset
function on the latest load function data returned for the form.
defaults
didn't infer the input type, and didn't generate correctSuperValidated
data, makingsuperForm
confused. Also fixed type signature and removed thejsonSchema
option that wasn't applicable.- Using
goto
in events didn't work when the target page redirected. FormPath
andFormPathLeaves
didn't handle fields with typeunknown
andany
.- Missing boolean fields were valid in strict mode.
get
andset
accessor foronChange
.submit
method forsuperForm
, a convenience instead of using requestSubmit. Requiresuse:enhance
or that aHTMLElement
inside the form (or the form itself) is passed as an argument.
- Type parameter was missing in
ChangeEvent
, which should be of the inferred schema type. - Type for
onChange.paths
wasn't strongly typed toFormPath
. - Initial data was dereferenced after calling
superForm
, so it wasn't possible to update it when usingreset
. FormOptions
type required a type parameter that should've been defaulted toRecord<string, unknown>
.- Auto-overflow on SuperDebug, for small spaces.
- Added
config
option to Valibot adapter, for the SchemaConfig type.
- Nullable fields weren't always detected in JSON Schemas.
- Constraints weren't added when using default values for Arktype, Vine and Valibot schemas.
- Fixed null support for Joi, Arktype and Vine schemas.
- Depending on the JSON Schema, dates were sometimes set to
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.
- Added
focusOnError
option toSuperForm.validateForm
type (it was only in the implementation). - Enums could not be detected as an invalid value if the posted value was an empty string, instead it defaulted to the enum first value.
$posted
was reset by mistake tofalse
after posting, whenresetForm
option was true.
- VineJS adapter!
- Added
focusOnError
option tovalidateForm
, defaulttrue
.
- Autofocus is now working when using
validateForm({ update: true })
. - Default values are now applied properly for single-type unions, even a mix of integers and numbers.
- SuperStruct types,
$errors
primarily, didn't handle nested data properly.
- The inferred type parameters were swapped in
message
, it can now be used to specify the message type.
- Enums can now be required 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 usingdataType: 'json'
.
superForm.fields
was a rarely used and lesser version offormFieldProxy
, switch to that instead.- Removed
fields
options when setting tainted status. - Remvoed
message
parameter inonError
event, use$message
directly instead.
- Adapters required for validation! Import from
sveltekit-superforms/adapters
and usesuperValidate(zod(schema))
instead ofsuperValidate(schema)
. If type parameters are used, it must now be wrapped withInfer
for schemas. - Default
superForm
options now follow SvelteKit more closely:resetForm: true
andtaintedMessage: false
are default now. Adddefine: { SUPERFORMS_LEGACY: true }
invite.config.ts
to keep the old behavior. superValidateSync
is renamed todefaults
. 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 tovalueErrors
.- 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 beundefined
. - If
superValidate
is called with just the schema, the default values aren't validated (i.e. no side-effects for default values) unlesserrors
is set totrue
. - Properties with default values don't have
required
in their constraints anymore. - Form id cannot be
undefined
anymore, must bestring
. (Set automatically by default now). flashMessage.onError.message
option insuperForm
renamed toflashMessage.onError.flashMessage
.constraints
are now optional in theSuperValidated
type, and are returned only when loading data, not posting. This is only relevant if you modify constraints before callingsuperForm
.- Removed the
defaultValidators
option,'clear'
can now be set directly onvalidators
instead. - Removed the
emptyIfZero
setting fromnumberProxy
andintProxy
. validate()
called with no arguments is renamed tovalidateForm()
and can take two extra options,update
andschema
.
- 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?)
andsuperForm.isTainted($tainted)
for better tainted fields check. - File upload support! Use
withFiles
when returning in form actions:return withFiles({ form })
. - SuperDebug now displays
File
andFileList
. - All proxies can now take the whole
superForm
object (previously only theform
store was accepted), with an extrataint
option to prevent tainting. taintedMessage
can now be an async function resolving totrue
if navigation should be allowed, despite the form being tainted.- Added an
onChange
event tosuperForm
, that returns a list of modified fields whenever$form
is updated. - Added
'zero'
to the empty option ofnumberProxy
andintProxy
. Also addedinitiallyEmptyIfZero
option, to show the placeholder for numeric inputs, which would otherwise display0
.