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.fieldswas a rarely used and lesser version offormFieldProxy, switch to that instead.- Removed
fieldsoptions when setting tainted status. - Remvoed
messageparameter inonErrorevent, use$messagedirectly instead.
Changed
- Adapters required for validation! Import from
sveltekit-superforms/adaptersand usesuperValidate(zod(schema))instead ofsuperValidate(schema). If type parameters are used, it must now be wrapped withInferfor schemas. - Default
superFormoptions now follow SvelteKit more closely:resetForm: trueandtaintedMessage: falseare default now. Adddefine: { SUPERFORMS_LEGACY: true }invite.config.tsto keep the old behavior. superValidateSyncis renamed todefaults. It returns default values for the schema, and does no validation anymore. Use+page.tsif initial validation is required, as described on the SPA page.arrayProxy:fieldErrorsrenamed 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
superformClientadapter. The input for the validator functions can now beundefined. - If
superValidateis called with just the schema, the default values aren't validated (i.e. no side-effects for default values) unlesserrorsis set totrue. - Properties with default values don't have
requiredin their constraints anymore. - Form id cannot be
undefinedanymore, must bestring. (Set automatically by default now). flashMessage.onError.messageoption insuperFormrenamed toflashMessage.onError.flashMessage.constraintsare now optional in theSuperValidatedtype, and are returned only when loading data, not posting. This is only relevant if you modify constraints before callingsuperForm.- Removed the
defaultValidatorsoption,'clear'can now be set directly onvalidatorsinstead. - Removed the
emptyIfZerosetting fromnumberProxyandintProxy. validate()called with no arguments is renamed tovalidateForm()and can take two extra options,updateandschema.
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
withFileswhen returning in form actions:return withFiles({ form }). - SuperDebug now displays
FileandFileList. - All proxies can now take the whole
superFormobject (previously only theformstore was accepted), with an extrataintoption to prevent tainting. taintedMessagecan now be an async function resolving totrueif navigation should be allowed, despite the form being tainted.- Added an
onChangeevent tosuperForm, that returns a list of modified fields whenever$formis updated. - Added
'zero'to the empty option ofnumberProxyandintProxy. Also addedinitiallyEmptyIfZerooption, to show the placeholder for numeric inputs, which would otherwise display0.