Socket
Book a DemoInstallSign in
Socket

@linode/validation

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@linode/validation

Yup validation schemas for use with the Linode APIv4

latest
Source
npmnpm
Version
0.73.0
Version published
Maintainers
1
Created
Source

Linode API Validation Schemas

Usage

This library consists of Yup schemas corresponding to the endpoints of the Linode API, intended to be used for client-side validation. They closely (though not exactly) match the validation that is run by the API back-end when a request is received. They can be used to validate API request payloads manually or to validate forms (for example through Formik’s validationSchema). They also work well with the @linode/api-v4 package.

Manual Validation

import { CreateLinodeSchema } from '@linode/validation';

const payload = { label: 'My Linode', type: 'g6-standard-1' };
CreateLinodeSchema.validateSync(payload);
// Uncaught: u [ValidationError]: Region is required.

With the @linode/api-v4 package

NOTE: This feature is in development.

import { createLinode } from '@linode/api-v4';
import { CreateLinodeSchema } from '@linode/validation';

const payload = { label: 'My Linode', type: 'g6-standard-1' };
createLinode(payload, { schema: CreateLinodeSchema }).catch((error) => {
  console.log(error);
});

// { field: 'region', reason: 'Region is required.' }

Why is it a separate library?

These schemas were originally included in the @linode/api-v4 package by default, and automatically applied before any network request was made. This worked well in the early days of Cloud Manager, especially before @linode/api-v4 was published as a separate package. However, as the project grew, this setup caused a few problems:

  • Coupling the request handlers and validation schemas meant that it wasn't possible to turn client-side validation off, which isn't a good fit for a public package.
  • The validation doesn't match the API’s exactly. There are some things, such as uniqueness, that are difficult to validate on the client. There are some additional cases where the validation is too complex, and we made a decision to fall back on the backend validation. This was acceptable when the schemas were only used internally by the Cloud Manager, but can lead to confusion for external users (in fact it's unlikely that most external users were even aware that validation was happening on the client side).
  • The auto-validation meant that we were double-validating in many cases; when using Formik, for example, the same schema is run on form submit, then run again in the JS client.
  • The api-v4 bundle was too big, and the schemas were a big part of it. This is unfortunate especially since not everyone necessarily wants to run client validation.

Keywords

linode

FAQs

Package last updated on 26 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.