surimi

Surimi logo

Documentation surimi on npm GitHub Repo stars

surimi - Safe SASS validation library

Make your SCSS/SASS safer with surimi. Define a schema for your data and ensure users use it correctly!

[!NOTE]
Documentation and reference are now available on our website, surimi.dev. For a quick intro into surimi, check out surimi.dev/intro

installation

Surimi is available as an npm package

# npm
npm install surimi
# pnpm
pnpm add surimi

or via a CDN like unpkg. To load it from a CDN, just @use it in your Sass file:

@use 'https://unpkg.com/surimi@latest' as s;

introduction

@use 'surimi' as s;

$my-number-schema: s.number(
  $gte: 18,
);

$my-string-schema: s.string(
  $min-length: '4',
  $starts-with: 'su',
  $ends-with: 'mi',
);

@include s.validate($my-number-schema, 15); // Oh-oh, an error!
@include s.validate($my-string-schema, 'tofu'); // No way!

You will recognize many of the properties - they are simple strings similar to ‘zod’ or ‘yup’. And if you do put a wrong one.. We got you covered!

[surimi] `string.min` is not a valid validator. Allowed validators are: [eq, in, not-in, contains, not-contains, ... max-length, min-length]

All surimi methods are validated themselves - leaving zero room for errors. Of course, validation errors look just as nice:

[surimi] Value must be greater than or equal to 18

For a full introduction, visit our docs, or check out the reference