# garbagescript

> This is an experimental scripting language designed specifically for data validation. It is intended to be easy to understand and adopt quickly.

Latest version **1.6.3** (published 2026-02-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install garbagescript
pnpm add garbagescript
yarn add garbagescript
bun add garbagescript
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.6.3 |
| Published | 2026-02-10 |
| First published | 2023-10-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 90.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | modem |

## Links

- npm: https://www.npmjs.com/package/garbagescript
- npm.io page: https://npm.io/package/garbagescript

## Recent versions

- 1.6.3 (latest) — 2026-02-10
- 1.6.2 — 2025-10-06
- 1.6.1 — 2024-03-09
- 1.6.0 — 2024-01-16
- 1.5.3 — 2024-01-12
- 1.5.2 — 2024-01-12
- 1.5.0 — 2024-01-07
- 1.4.1 — 2024-01-03
- 1.4.0 — 2024-01-03
- 1.3.1 — 2023-12-27
- 1.3.0 — 2023-12-27
- 1.2.2 — 2023-12-24
- 1.2.1 — 2023-12-24
- 1.2.0 — 2023-11-10
- 1.1.0 — 2023-10-28
- … 3 more at https://npm.io/package/garbagescript/versions

## README

This is an experimental scripting language designed specifically for data validation. It is intended to be easy to understand and adopt quickly.

## Usage

Basic evaluation usage:

```js
import { createScript } from 'garbagescript'

// Create a simple multiplication script
const gs = createScript(`$input * 10`)

// Evaluate the script, providing the predetermined `$input` variable
const result = gs.evaluate({ $input: 5 }) // 50
```

As a validation utility:

```ts
import { createScript } from 'garbagescript'

const { validate } = createScript(`
validate {
  if $display_name == "" {
    reject "Display name is required"
  }

  if $password:length < 8 {
    reject "Password must be at least 8 characters long"
  }

  if $birth_date > today - 18 years {
    reject "You must be 18 years or older"
  }
}
`)

const result = validate({
  $display_name: 'Example',
  $password: 'secret',
  $birth_date: new Date(1980, 3, 15),
})

const errors = result.validationErrors
if (errors.length > 0) {
  // Do something with the errors, in this case there is
  // only one regarding the password:
  for (const error of errors) {
    // "Password must be at least 8 characters long"
    console.log(error.message)
  }
}
```

---
_Source: https://npm.io/package/garbagescript · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
