Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@janiscommerce/superstruct

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@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

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
360
increased by3.15%
Maintainers
1
Weekly downloads
 
Created
Source

superstruct

Build Status Coverage Status npm version

The following package complements the superstruct package, the same adds some methods to easily validate different types of data

Installation

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

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);

FAQs

Package last updated on 20 Sep 2022

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc