New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

indicative-compiler

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

indicative-compiler

Compiles parser tree into array of top level functions

  • 6.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
increased by29.17%
Maintainers
1
Weekly downloads
 
Created
Source

UsageWhy?FeaturesExamplesDocumentation


Compiler

The compiler package takes the parser input and creates a highly performant function that can be cached to run validations with runtime data. Below are some benchmarks ran on the output function of compiler with dummy rules.

  • Macbook Pro (2.2 GHz Intel Core i7): 2,281,616 ops/sec

Usage

Install the package from npm

npm i indicative-compiler

# yarn user
yarn add indicative-compiler

and then use it as follows

const { validationCompiler } = require('indicative-compiler')

const rulesSchema = {
  username: 'required'
}

const validations = {
  required: {
    async: false,
    validate () {
      return true
    }
  }
}

const messagesSchema = {
  'username.required': 'Username is required'
}

const validate = validationCompiler(rulesSchema, validations, messagesSchema)

The above code will output a pre-compiled function, that can be used to run validations using runtime data.

const { vanilla } = require('indicative-formatters')
const config = {}

/**
 * Bail true means stop on first validation error
 */
const bail = true

validate(data, vanilla, config, bail)
  .then(console.log)
  .catch(console.error)

Keywords

FAQs

Package last updated on 29 Mar 2019

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