github unnoq/orpc v1.8.9

10 hours ago

Request Validation Plugin docs

The Request Validation Plugin ensures that only valid requests are sent to your server. This is especially valuable for applications that depend on server-side validation.

You can simplify your frontend by removing heavy form validation libraries and relying on oRPC's validation errors instead, since input validation runs directly in the browser and is highly performant.

export function ContactForm() {
  const [error, setError] = useState()

  const handleSubmit = async (form: FormData) => {
    try {
      const output = await client.someProcedure(parseFormData(form))
      console.log(output)
    }
    catch (error) {
      setError(error)
    }
  }

  return (
    <form action={handleSubmit}>
      <input name="user[name]" type="text" />
      <span>{getIssueMessage(error, 'user[name]')}</span>

      <input name="user[emails][]" type="email" />
      <span>{getIssueMessage(error, 'user[emails][]')}</span>

      <button type="submit">Submit</button>
    </form>
  )
}

Note

If you find oRPC valuable and would like to support its development, you can do so here.

   🚀 Features

   🐞 Bug Fixes

  • contract: Cannot be named without a reference AsyncIteratorClass  -  by @unnoq (c68ce)
    View changes on GitHub

Don't miss a new orpc release

NewReleases is sending notifications on new releases.