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

remix-form-class-validator

v0.0.1

Published

Use class-validator in your Remix app forms.

Readme

Remix form class-validator

Simple helper to parse Remix FormData and validate them using class-validator.

Features

  • Server-side FormData parsing and validation using class-validator
  • Provides typesafe access to parsed parameters and validation errors
  • Support for arrays and nested attributes

Usage

Start by defining the DTO class that will hold your parameters, and the respective validations using class-validator:

class PersonDto {
  @IsNotEmpty()
  @MinLength(2)
  name: string;
  @Min(0)
  @Max(150)
  age: number;
}

Declare the route action and use parseRequestParams to parse and validate your parameters into your declared DTO:

const action: ActionFunction = async ({ request }) => {
  const params = await parseRequestParams(request, PersonDto);

  if (params.errors) {
    console.log("Form data is invalid", { errors: params.errors });
  } else {
    console.log("Form data is valid", { data: params.data });
  }

  return json(params);
};

Finally you just need to declare your form and use useActionData to access any errors resulting from validating your DTO.

type ActionData = ParseRequestParamsReturn<PersonDto>;

const SimpleForm = () => {
  const actionData = useActionData<ActionData>();

  return (
    <Form style={{ maxWidth: 400 }} method="post">
      <Input name="name" label="Name:" defaultValue={actionData?.data.name} />
      <InputError errors={actionData?.errors?.name} />
      <Input name="age" label="Age:" defaultValue={actionData?.data.age} />
      <InputError errors={actionData?.errors?.age} />
      <button type="submit" style={{ marginTop: "1rem" }}>
        Submit
      </button>
    </Form>
  );
};

Installation

To install simply run the following command:

$ npm install --save remix-form-class-validator

Because this library uses class-transformer you will need to import the reflect-metadata shim. On your entry.server.tsx file add the following import statement to import reflect-metadata:

// entry.server.tsx
import "reflect-metadata";

Configure Typescript

Because class-validator relies on annotations to perform validations, you should add the following to your tsconfig.json:

{
  // ...
  "compilerOptions": {
    // ...
    "strictPropertyInitialization": false,
    "experimentalDecorators": true
    // ...
  }
  // ...
}

Examples

You can check some example apps on the examples folder.