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

fefe

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fefe - npm Package Compare versions

Comparing version 3.0.0-beta.1 to 3.0.0-beta.2

dist/pipe.d.ts

2

dist/array.d.ts

@@ -1,2 +0,2 @@

import { Validator } from './validate';
import { Validator } from './transformer';
export interface ArrayOptions {

@@ -3,0 +3,0 @@ minLength?: number;

@@ -1,2 +0,2 @@

import { Validator } from './validate';
import { Validator } from './transformer';
export declare function boolean(): Validator<boolean>;

@@ -1,2 +0,2 @@

import { Validator } from './validate';
import { Validator } from './transformer';
export interface DateOptions {

@@ -3,0 +3,0 @@ min?: Date;

@@ -1,2 +0,2 @@

import { Validator } from './validate';
import { Validator } from './transformer';
export declare function enumerate<T extends (string | number)[]>(...args: T): Validator<T[number]>;
export * from './errors';
export * from './result';
export * from './validate';
export * from './throw';
export * from './transformer';
export * from './array';

@@ -14,3 +15,4 @@ export * from './boolean';

export * from './parse-number';
export * from './pipe';
export * from './string';
export * from './union';

@@ -15,3 +15,4 @@ "use strict";

__exportStar(require("./result"), exports);
__exportStar(require("./validate"), exports);
__exportStar(require("./throw"), exports);
__exportStar(require("./transformer"), exports);
__exportStar(require("./array"), exports);

@@ -27,4 +28,5 @@ __exportStar(require("./boolean"), exports);

__exportStar(require("./parse-number"), exports);
__exportStar(require("./pipe"), exports);
__exportStar(require("./string"), exports);
__exportStar(require("./union"), exports);
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { Validator } from './validate';
import { Validator } from './transformer';
export interface NumberOptions {

@@ -3,0 +3,0 @@ min?: number;

@@ -1,2 +0,2 @@

import { Validator, ValidatorReturnType } from './validate';
import { Validator, ValidatorReturnType } from './transformer';
export declare type ObjectValueValidator = Validator<unknown> & {

@@ -3,0 +3,0 @@ optional?: boolean;

@@ -1,2 +0,2 @@

import { Transformer } from './validate';
import { Transformer } from './transformer';
export declare function parseBoolean(): Transformer<string, boolean>;

@@ -1,4 +0,4 @@

import { Transformer } from './validate';
import { Transformer } from './transformer';
export declare function parseDate({ iso }?: {
iso?: boolean;
}): Transformer<string, Date>;

@@ -1,2 +0,2 @@

import { Transformer } from './validate';
import { Transformer } from './transformer';
export declare function parseJson(): Transformer<string, unknown>;

@@ -1,2 +0,2 @@

import { Transformer } from './validate';
import { Transformer } from './transformer';
export declare function parseNumber(): Transformer<string, number>;

@@ -1,2 +0,2 @@

import { Validator } from './validate';
import { Validator } from './transformer';
export interface StringOptions {

@@ -3,0 +3,0 @@ minLength?: number;

@@ -1,2 +0,2 @@

import { Validator, ValidatorReturnType } from './validate';
import { Validator, ValidatorReturnType } from './transformer';
export declare function union<T extends Validator<unknown>[]>(...validators: T): Validator<ValidatorReturnType<T[number]>>;
{
"name": "fefe",
"version": "3.0.0-beta.1",
"version": "3.0.0-beta.2",
"description": "Validate, sanitize and transform values with proper types.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -53,12 +53,10 @@ # fefe

In this example a `string` needs to be parsed as a `Date`. Chaining functions can be achieved by the standard functional tools like `flow` and `chain` in [fp-ts](https://www.npmjs.com/package/fp-ts).
In this example a `string` needs to be parsed as a `Date`. You can use `pipe()` to pass a value through multiple functions:
```typescript
import { object, parseDate, string, ValidatorReturnType } from 'fefe'
import { chain } from 'fp-ts/lib/Either'
import { flow } from 'fp-ts/lib/function'
import { object, parseDate, pipe, string, ValidatorReturnType } from 'fefe'
const sanitizeMovie = object({
title: string(),
releasedAt: flow(string(), chain(parseDate()))
releasedAt: pipe(string()).pipe(parseDate())
})

@@ -77,2 +75,4 @@

**Note:** Chaining functions can also be achieved by the standard functional tools like `flow` and `chain` in [fp-ts](https://www.npmjs.com/package/fp-ts).
#### Parse a value on demand (sanitize)

@@ -83,9 +83,7 @@

```typescript
import { date, parseDate, union } from 'fefe'
import { chain } from 'fp-ts/lib/Either'
import { flow } from 'fp-ts/lib/function'
import { date, parseDate, pipe, union } from 'fefe'
const sanitizeDate = union(
date(),
flow(string(), chain(parseDate()))
pipe(string()).pipe(parseDate())
)

@@ -96,19 +94,13 @@ ```

This is a more complex example that can be applied to parsing environment variables or query string parameters. Again, we use `flow` and `chain` to compose functions. Here, we also add a custom function that splits a string into an array.
This is a more complex example that can be applied to parsing environment variables or query string parameters. Again, we use `pipe` to compose functions. Here, we also add a custom function that splits a string into an array.
```typescript
import { object, parseJson, string, success } from 'fefe'
import { chain } from 'fp-ts/lib/Either'
import { flow } from 'fp-ts/lib/function'
import { object, parseJson, pipe, string, success } from 'fefe'
const parseConfig = object({
gcloudCredentials: flow(
string()
chain(parseJson()),
chain(object({ secret: string() }))
),
whitelist: flow(
string(),
chain(secret => success(str.split(',')))
)
gcloudCredentials: pipe(string())
.pipe(parseJson())
.pipe(object({ secret: string() })),
whitelist: pipe(string()
.pipe(secret => success(str.split(',')))
})

@@ -262,2 +254,6 @@

### `pipe(validator1: Transformer<A, B>): Pipe<A, B>`
Returns a transformer that offers a `.pipe(validator2: Transformer<B, C>): Pipe<A, C>` method.
### `string(options?): Validator<string>`

@@ -264,0 +260,0 @@

Sorry, the diff of this file is not supported yet

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