npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hermiforge-decorix/svelte-superforms

v0.4.0

Published

Superforms (sveltekit-superforms) validation adapter for Decorix metadata.

Downloads

556

Readme

@hermiforge-decorix/svelte-superforms

Decorix

Superforms (sveltekit-superforms) validator adapter for Decorix metadata. Unlike the other framework adapters, this implements Superforms' own ValidationAdapter<Out, In> contract — the same shape its built-in zod()/valibot() helpers return — since Superforms requires that exact contract from superValidate(adapter)/superForm.

Full usage guide: docs/ (narrative walkthrough beyond this package's API reference).

Requires SvelteKit (@sveltejs/kit), not plain Svelte — sveltekit-superforms is built around SvelteKit's server load/form actions. If you only use Svelte without SvelteKit, use @hermiforge-decorix/svelte-felte instead.

Install

pnpm add @hermiforge-decorix/core @hermiforge-decorix/svelte-superforms sveltekit-superforms @sveltejs/kit svelte

Peer dependencies: svelte, @sveltejs/kit, sveltekit-superforms@^2.30.0. @hermiforge-decorix/json-schema is a direct (non-optional) dependency, reused internally to build the adapter's required jsonSchema field. @hermiforge-decorix/zod is only needed if you opt into Zod-backed validation instead of the core facade — see Validator Notes below.

Decorated Class

// +page.server.ts
import {Email, MinLength, Model, Required} from '@hermiforge-decorix/core';
import {createSuperformsValidatorAdapter} from '@hermiforge-decorix/svelte-superforms';
import {superValidate} from 'sveltekit-superforms/server';
import {fail} from '@sveltejs/kit';

@Model('SignupDto')
class SignupDto {
  @Required('Name is required')
  @MinLength(2, 'Name is too short')
  name!: string;

  @Required('Email is required')
  @Email('Invalid email')
  email!: string;
}

const adapter = createSuperformsValidatorAdapter(SignupDto);

export const load = async () => ({form: await superValidate(adapter)});

export const actions = {
  default: async ({request}) => {
    const form = await superValidate(request, adapter);
    if (!form.valid) return fail(400, {form});
    // ... form.data is validated
    return {form};
  }
};
<!-- +page.svelte -->
<script lang="ts">
  import {superForm} from 'sveltekit-superforms';
  let {data} = $props();
  const {form, errors, enhance} = superForm(data.form);
</script>

<form method="POST" use:enhance>
  <input name="name" bind:value={$form.name} />
  {#if $errors.name}<span>{$errors.name}</span>{/if}
  <input name="email" bind:value={$form.email} />
  {#if $errors.email}<span>{$errors.email}</span>{/if}
</form>

T is inferred straight from SignupDtoform.data above is already typed SignupDto, no separate form-values type or cast needed.

Builder Model

import {model, stringField} from '@hermiforge-decorix/core';
import {createZodValidatorAdapter} from '@hermiforge-decorix/zod';
import {createSuperformsValidatorAdapter} from '@hermiforge-decorix/svelte-superforms';

const SignupDto = model('SignupDto', {
  name: stringField().required('Name is required').minLength(2, 'Name is too short'),
  email: stringField().required('Email is required').email('Invalid email')
});

const adapter = createSuperformsValidatorAdapter(SignupDto, {
  initialValues: {name: 'Ada'},
  validator: createZodValidatorAdapter()
});

Validator Notes

createSuperformsValidatorAdapter always returns a full ValidationAdapter, whether or not options.validator is passed: when omitted, it falls back to Decorix's core validator facade — no extra install needed. Pass an explicit adapter through options.validator only if you want a different engine, such as Zod via createZodValidatorAdapter(). registerZodValidator()'s global registration is not consulted here.

Superforms' own built-in adapters derive constraints (HTML input constraints), shape (an array/object marker tree), and defaults from a JSON Schema using internal helpers (constraints(), schemaShape(), defaultValues()) that are not part of sveltekit-superforms/adapters's public API — verified against the installed package's dist/adapters/index.js, which only re-exports per-library helpers (zod, valibot, ...) and ValidationAdapter's type, not createAdapter/createJsonSchema or the derivation helpers. This adapter therefore builds constraints, shape, and defaults directly from Decorix field metadata instead (src/defaults.ts, src/shape.ts), and builds jsonSchema from @hermiforge-decorix/json-schema's toJsonSchema.

defaults uses type-appropriate values ('' for strings, 0 for numbers, false for booleans, the first enum value, [] for arrays) rather than undefined, since Superforms' bound inputs need concrete values — pass options.initialValues to override any of them (e.g. for date fields, which default to undefined since there is no safe non-null default).

id is set to the Decorix model's registered name (already a stable, unique identifier) rather than a schema hash.

License

LGPL-3.0-or-later — see the repository LICENSE.