
Security News
Python Adopts Standard Lock File Format for Reproducible Installs
Python has adopted a standardized lock file format to improve reproducibility, security, and tool interoperability across the packaging ecosystem.
@motet-a/validate
Advanced tools
[](https://travis-ci.org/motet-a/validate) [](https://coveralls.io/github/motet-a/valida
Well, I was unable to find the perfect validation library. I like these ones:
prop-types. This one is truly great. It’s not the most customizable, not the most chainable and it’s not really suitable outside React, but it perfectly does its job.
Joi. Chainable but a bit bloated. You can do a lot with Joi, but it’s not so simple, you can’t always guess what it does without reading the documentation.
This library is an attempt to write a cleaner and simplified Joi, using modern JS features.
Since it uses Reflect
, it is hard to use it in old environments.
First of all:
const V = require('@motet-a/validate')
V
is a validation function which returns its argument, requires
a value and throws on error:
V(123) // → 123
V(0) // → 0
V(null) // → throws V.ValidationError
V(undefined) // → throws V.ValidationError
Of course, you can allow null
and undefined
:
V.optional(null) // → null
V.optional(undefined) // → undefined
You can restrict the type:
V.string('valid') // → 'valid'
V.string(123) // → throws
V.number(NaN) // → throws
V.number(123) // → 123
V.number.integer(123) // → 123
V.object({}) // → {}
V.bool(false) // → false
V.integer
is a shortcut for V.number.integer
.
V
is a validator, V.string
is a new validator. Every validator is
immutable.
You can mix up everything:
V.optional.string(null) // → null
V.string.optional(null) // → null
You can restrict types of objects and arrays:
V.array.of(V.number.positive)([-1]) // throws (number not positive)
V.object.of(V.string.lower)
You can also shape objects, use rexgexp, extract and reuse field
validators and much more. See the examples/
directory.
Joi and prop-types.
FAQs
[](https://travis-ci.org/motet-a/validate) [](https://coveralls.io/github/motet-a/valida
The npm package @motet-a/validate receives a total of 0 weekly downloads. As such, @motet-a/validate popularity was classified as not popular.
We found that @motet-a/validate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Python has adopted a standardized lock file format to improve reproducibility, security, and tool interoperability across the packaging ecosystem.
Security News
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.