# @janiscommerce/superstruct

> ![Build Status](https://github.com/janis-commerce/superstruct/workflows/Build%20Status/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/janis-commerce/superstruct/badge.svg?branch=master)](https://coveralls.io/github/janis-commerce/superst

Latest version **1.2.2** (published 2025-03-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install @janiscommerce/superstruct
pnpm add @janiscommerce/superstruct
yarn add @janiscommerce/superstruct
bun add @janiscommerce/superstruct
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2025-03-25 |
| First published | 2020-02-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Janis |
| Maintainers | janiscommerce |

## Links

- npm: https://www.npmjs.com/package/@janiscommerce/superstruct
- Repository: https://github.com/janis-commerce/superstruct
- Homepage: https://github.com/janis-commerce/superstruct.git#readme
- Issues: https://github.com/janis-commerce/superstruct/issues
- npm.io page: https://npm.io/package/@janiscommerce/superstruct

## Dependencies (1)

- [superstruct](https://npm.io/package/superstruct.md) 0.6.2

## Recent versions

- 1.2.2 (latest) — 2025-03-25
- 1.2.1 — 2022-09-20
- 1.2.0 — 2021-03-05
- 1.1.1 — 2020-03-19
- 1.1.0 — 2020-03-13
- 1.0.0 — 2020-02-20

## README

# superstruct

![Build Status](https://github.com/janis-commerce/superstruct/workflows/Build%20Status/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/janis-commerce/superstruct/badge.svg?branch=master)](https://coveralls.io/github/janis-commerce/superstruct?branch=master)
[![npm version](https://badge.fury.io/js/%40janiscommerce%2Fsuperstruct.svg)](https://www.npmjs.com/package/@janiscommerce/superstruct)


The following package complements the [superstruct](https://github.com/ianstormtaylor/superstruct) package, the same adds some methods to easily validate different types of data

## Installation
```sh
npm install @janiscommerce/superstruct
```
## Available custom structs types
The custom types that you can use in addition to the superstruct are:
- **`email`** This type checks if is a valid email
- **`URL`** This type checks if is a valid URL
- **`empty`** This type checks if it's an empty string, array or a falsy value
- **`!empty`** This type checks if it's not an empty string, array or a falsy value
- **`lowercase`** This type checks if is a valid lowercase string
- **`uppercase`** This type checks if is a valid uppercase string
- **`camelcase`** This type checks if is a valid camelcase string
- **`numeric`** This type checks if is a valid numeric value
- **`md5`** This type checks if is a valid md5 hash
- **`JSON`** This type checks if is a valid JSON
- **`ISODate`** This type checks if is a valid ISO Date
- **`integer`** This type checks if is a integer number
- **`positive`** This type checks if is a positive number
- **`positiveOrZero`** This type checks if is a positive number or zero
- **`objectId`** This type checks if is a ObjectId with 24 characters
- **`UUID`** This type checks if is a V4 UUID
- **`hexColor`** This type checks if is a Hexadecimal Color

## Usage
```js
const { struct } = require('@janiscommerce/superstruct');

const userStruct = struct({
	name: 'string',
	email: 'email',
	age: 'number',
	password: 'md5',
	image: 'URL',
	mainColor: 'hexColor
});

const userData = {
	name: 'John Doe',
	email: 'emai@asd.com',
	age: 28,
	password: 'be5b0158b79c90c8358990f34ec18d43',
	image: 'https://gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?s=200',
	hexColor: '#123456'
};

userStruct(userData);
```

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