Releases: ciscoheat/sveltekit-superforms
Releases Β· ciscoheat/sveltekit-superforms
v2.2.1
Migration guide: https://superforms.rocks/migration-v2
More detailed list of what's new: https://superforms.rocks/whats-new-v2
Fixed
- 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.
v2.2.0
Migration guide: https://superforms.rocks/migration-v2
More detailed list of what's new: https://superforms.rocks/whats-new-v2
Added
- VineJS adapter!
- Added
focusOnError
option tovalidateForm
, defaulttrue
.
Fixed
- 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.
Changed
- The inferred type parameters were swapped in
message
, it can now be used to specify the message type.
v2.1.0
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 usingdataType: 'json'
.
v2.0.0
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 offormFieldProxy
, switch to that instead.- Removed
fields
options when setting tainted status. - Remvoed
message
parameter inonError
event, use$message
directly instead.
Changed
- 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
.
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?)
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
.
v1.13.4
v1.13.3
v1.13.2
v1.13.1
v1.12.0
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
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
oruntaint-all
, client-side validation was prevented. - The
novalidate
andformnovalidate
attributes on forms and buttons weren't respected. (#287)