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

data-validator

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-validator

  • 1.1.3
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

This is a Ruby version of gfx/p5-Data-Validator + xaicron/p5-Data-Validator-Recursive.

Compare below versus https://metacpan.org/pod/Data::Validator

rule = Data::Validator.new(
  'uri'        => { isa: String, xor: %w(schema host path_query) },
  'schema'     => { isa: String, default: 'http' },
  'host'       => { isa: String },
  'path_query' => { isa: String, default: '/' },
  'method'     => { isa: String, default: 'GET' },
)

args = rule.validate('uri' => 'http://example.com')

and below versus https://metacpan.org/pod/Data::Validator::Recursive

# create a new rule
rule = Data::Validator::Recursive.new(
    'foo' => String,
    'bar' => { isa: Integer },
    'baz' => {
        isa: Hash, # default
        rule: {
            'hoge' => { isa: String, optional: 1 },
            'fuga' => Integer
        },
    },
)

# input data for validation
input = {
    'foo' => 'hoge',
    'bar' => 1192,
    'baz' => {
        'hoge' => 'kamakura',
        'fuga' => 1185,
    },
}

# do validation
params = rule.validate(input) # raises automatically on error
limitations
  • Data::Validator is recursive by default. There is no such thing like a nonrecursive validator.
  • ->with('Method') does not make sense to us, so not supported.
  • does also does not make sense. Not supported.
  • We do distinguish arrays and hashes unlike perl. There also are no ->with('Sequenced').
  • I don't understand the actual needs of xor; all examples seems illustravive to me. Other validators like JSON Schema (cf zigorou/perl-JSV) do not have this. This lack of understanding can negatively impact.
  • I don't understand why @gfx thinks it's fast.

FAQs

Package last updated on 08 Mar 2021

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