Socket
Socket
Sign inDemoInstall

validate-value

Package Overview
Dependencies
10
Maintainers
5
Versions
91
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.1.7 to 9.2.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

# [9.2.0](https://github.com/thenativeweb/validate-value/compare/9.1.7...9.2.0) (2022-01-17)
### Features
* Improve readme. ([#405](https://github.com/thenativeweb/validate-value/issues/405)) ([98687b8](https://github.com/thenativeweb/validate-value/commit/98687b82c7b8210e8e8255dc2b170b7b306cf469))
## [9.1.7](https://github.com/thenativeweb/validate-value/compare/9.1.6...9.1.7) (2021-12-07)

@@ -2,0 +9,0 @@

2

package.json
{
"name": "validate-value",
"version": "9.1.7",
"version": "9.2.0",
"description": "validate-value validates values against JSON schemas.",

@@ -5,0 +5,0 @@ "contributors": [

@@ -97,3 +97,3 @@ # validate-value

```javascript
```typescript
const user = {

@@ -104,8 +104,16 @@ username: 'Jane Doe',

const result = parser.parse(user);
const parsedValue = result.unwrapOrThrow();
const parseResult = parser.parse(user);
if (parseResult.hasError()) {
// The user object did not match the parser's schema. This should be handled.
} else {
// The user object was parsed successfully and the result's value can now be used.
doSomethingWithUser(parseResult.value);
}
```
After parsing, `parsedValue` will have the type `User`, since it was passed to the parser upon construction.
After parsing, the value in the returned `Result` will have the type `User`, since it was passed to the parser upon construction.
For details on the error handling in the example above, check the [documentation of the `Result` type in `defekt`](https://github.com/thenativeweb/defekt#using-result).
## Configuring the parser

@@ -115,3 +123,3 @@

```javascript
```typescript
const user = {

@@ -122,3 +130,3 @@ username: 'Jane Doe',

value.parse(user, { valueName: 'person', separator: '/' });
const parseResult = parser.parse(user, { valueName: 'person', separator: '/' });
```

@@ -130,6 +138,6 @@

```javascript
const { parse } = require('validate-value');
```typescript
import { parse } from 'validate-value';
parse(user, {
const parseResult = parse<User>(user, {
type: 'object',

@@ -136,0 +144,0 @@ properties: {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc