npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

schema-validatee

v0.0.1

Published

> Small type contoller for javascript. Powered by Lodash.

Downloads

4

Readme

Schema Control

Small type contoller for javascript. Powered by Lodash.

const Data = [
  { name: "john", mission: "teacher", age: 30, isOnline: false },
  { name: "mike", mission: "driver", age: 35, isOnline: true }
];

const Schema = {
  name: "string",
  mission: "string",
  age: "number",
  isOnline: "boolean"
};

SchemaControl([Schema], Data); //true

Installation

npm i schema-control or

yarn add schema-control

Usage

Using for simple data

const SchemaControl = require("schema-control"); //or using import

const Schema = "string";
const Data = "This is String :)";

SchemaControl(Schema, Data); // true

SchemaControl(Schema, 15); // false

SchemaControl(Schema, true); // false

const Schema = "string";
const StringArray = ["String 1", "String 2", "String 3"];

//To check the type of array, you must import the schema into an array

// butun elemanlarin turu string oldugu icin true doner

SchemaControl([Schema], StringArray); // true

const Schema = "string";
const ArrayData = ["String 1", "String 2", "String 3", 15];

// icinde number bir tip oldugu icin false donderir

SchemaControl([Schema], ArrayData); // false

Kendi Tipini olusturabilirsin

const SchemaControl = require("schema-control"); //or using import

const MySchema = {
  name: "string",
  mission: "string",
  age: "number",
  isOnline: "boolean"
};
const Data = { name: "john", mission: "teacher", age: 30, isOnline: false };

// eger obje gelirse icindeki fieldlerin key'ine ve tipine bakar

SchemaControl(MySchema, Data); //true

const MySchema = {
  name: "string",
  mission: "string",
  age: "number",
  isOnline: "boolean"
};
const Data = {
  name: "john",
  mission: "teacher",
  age: 30,
  isOnline: false,
  Nothin: "nothing"
};

// Data icinde Nothing olmamasi gerekir buyuzden false doner

SchemaControl(MySchema, Data); // false

Surekli ayni semayi kullanmak mi istiyorsun

const SchemaControl = require("schema-control"); //or using import
const MySchema = {
  name: "string",
  mission: "string",
  age: "number",
  isOnline: "boolean"
};

const SpecificSchema = SchemaControl(MySchema);

const Data_One = { name: "john", mission: "teacher", age: 30, isOnline: false };

const Data_Two = { name: "mike", mission: "driver", age: 40, isOnline: true };

SpecificSchema(Data_One); //true

SpecificSchema(Data_Two); //true

yada

const MySchema = {
  name: "string",
  mission: "string",
  age: "number",
  isOnline: "boolean"
};

const SpecificSchema = require("schema-control")(MySchema);

const Data_One = { name: "john", mission: "teacher", age: 30, isOnline: false };

const Data_Two = { name: "mike", mission: "driver", age: 40, isOnline: true };

SpecificSchema(Data_One); //true

SpecificSchema(Data_Two); //true

Birden fazla sema kotrolu de yapilabilir

eger SchemaControl fonksiyonunun ilk paramatresine uzunlugu 1 den fazla olan bir array verirseniz multi tip moduna gecer

  • basit tipler icin multi tip kontrolu
const SchemaControl = require("schema-control"); //or using import

const string = "strting";
const number = "number";

SchemaControl([string, number], 15); //true

SchemaControl([string, number], "This is string :)"); //true

// string yada number tipinden farkli bir tip gonderirseniz hata verir

SchemaControl([string, number], true); // false
  • karmasik tipler icin multi tip kontrolu
const SchemaControl = require("schema-control"); //or using import

const string = "strting";
const number = "number";

const ArrayData = ["string 1", "string 2", "string 3", 1, 2, 3];

// Array icindeki elemanlar i kontrol eder eger gonderilen tiplerden herhangi birine uyuyorsa onu dogru olarak alir

SchemaControl([string, number], ArrayData); //true

const ArrayData_Two = ["string 1", "string 2", "string 3", 1, 2, 3, true];

// arrayin icinde gonderilen tiplere uymayan bir tip oldugu icin false donderir

SchemaControl([string, number], ArrayData_Two); //false

eger arrayin elemanlarinin degilde kendisinin tipini kontrol etmek istiyorsaniz

const SchemaControl = require("schema-control"); //or using import

const string = "strting";
const number = "number";

const ArrayData = ["string 1", "string 2", "string 3"];

// tiplerin kendisinide array icine almaniz arrayin kendisinin genel olarak tipini kontrol etmesini saglar

// asagidaki kullanimda arrayin gelen tipi ya strin yada number olmak zorunda

SchemaControl([[string], [number]], ArrayData); //true

const ArrayData = ["string 1", "string 2", "string 3", 1];

// tiplerin icinde number olmasina ragmen bu false donderir sebebi ise  arrayin tipine bakmasi itemlerinin degil

SchemaControl([[string], [number]], ArrayData_Two); //false