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

jet-schema

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jet-schema - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

1

dist/jetSchema.js

@@ -66,3 +66,2 @@ "use strict";

defaults[key] = () => cloneFn(vals[0]);
console.log(vals);
validators[key] = (arg) => vals.some(item => item === arg);

@@ -69,0 +68,0 @@ }

2

package.json
{
"name": "jet-schema",
"version": "1.0.5",
"version": "1.0.6",
"description": "Simple, typescript-first schema validation tool",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -19,3 +19,3 @@ # Jet-Schema ✈️

## Introduction <a name="introduction"></a>
Most schema validation libraries have fancy functions for validating objects and their properties, but the problem is I usually already have a lot of my own custom validation logic specific for each of my applications (i.e. functions to check primitive-types, regexes for validating strings etc). The only thing that was making me use schema-validation libraries was trying to validate object properties. So I thought, why not figure out a way to integrate my all the functions I had already written with something that can validate them against object properties? Well **jet-schema** does just that :)
Most schema validation libraries have fancy functions for validating objects and their properties, but the problem is I usually already have a lot of my own custom validation logic specific for each of my applications (i.e. functions to check primitive-types, regexes for validating strings etc). The only thing that was making me use schema-validation libraries was trying to validate an object schema. So I thought, why not figure out a way to integrate my all the functions I had already written with something that can validate them against object properties? Well **jet-schema** does just that :)
<br/>

@@ -26,2 +26,4 @@

> If you're open to `jet-logger` but think writing your own validator functions could be tedious, you can copy-n-paste the file (https://github.com/seanpmaxwell/ts-validators/blob/master/src/validators.ts) into your application and add/remove validators as needed.
Reasons to use Jet-Schema 😎

@@ -57,3 +59,3 @@ - TypeScript first!

// Equivalent using "jet-schema" (other than "schema/transform", the other functions
// are defined elsewhere in the application)
// must be defined elsewhere in your application)
const User = schema<IUser>({

@@ -122,3 +124,2 @@ id: isRelKey,

Now that we have our schema function setup, let's make a schema: there are two ways to go about this, enforcing a schema from a type or infering a type from a schema. I'll show you some examples doing it both ways.
<br/>

@@ -165,3 +166,3 @@ > Personally, I like to create an interface first cause I feel like they are great way to document your data-types, but I know some people prefer to setup their schemas first and infer their types from that.

> If an object property is a mapped-type, then it must be initialized with the schema function. Just like with the parent schemas, you can also call `new`, `test`, `pick`, in addition to `default`. The value returned from `default` could be different from `new` if the schema is optional/nullable and the default value is `null` or `undefined`.
> **IMPORTANT:** If an object property is a mapped-type, then it must be initialized with the `schema` function. Just like with the parent schemas, you can also call `new`, `test`, `pick`, in addition to `default`. The value returned from `default` could be different from `new` if the schema is optional/nullable and the default value is `null` or `undefined`.

@@ -168,0 +169,0 @@

Sorry, the diff of this file is not supported yet

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