Huge News!Announcing our $40M Series B led by Abstract Ventures.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 1.0.1 to 1.1.0

6

dist/errors.d.ts

@@ -5,3 +5,3 @@ export declare class ExtendableError extends Error {

export interface FefeChildError {
key: string | number;
key: string | number | symbol;
error: FefeError;

@@ -13,6 +13,6 @@ }

readonly child?: FefeChildError;
readonly path: (string | number)[];
readonly path: (string | number | symbol)[];
readonly originalError: FefeError;
constructor(value: any, reason: string, child?: FefeChildError);
createParentError(parentValue: any, key: string | number): FefeError;
createParentError(parentValue: any, key: string | number | symbol): FefeError;
}

@@ -8,3 +8,3 @@ export { FefeError } from './errors';

export { number } from './number';
export { object } from './object';
export { object, optional } from './object';
export { parseBoolean } from './parse-boolean';

@@ -11,0 +11,0 @@ export { parseDate } from './parse-date';

@@ -17,2 +17,3 @@ "use strict";

exports.object = object_1.object;
exports.optional = object_1.optional;
var parse_boolean_1 = require("./parse-boolean");

@@ -19,0 +20,0 @@ exports.parseBoolean = parse_boolean_1.parseBoolean;

@@ -15,2 +15,3 @@ import { Validator } from './validate';

}): (value: unknown) => { [k in keyof D]: ObjectReturnType<D[k]>; };
export declare function optional<R>(validator: Validator<R>): ObjectOptions<R>;
export {};

@@ -52,2 +52,9 @@ "use strict";

exports.object = object;
function optional(validator) {
return {
validator,
optional: true
};
}
exports.optional = optional;
//# sourceMappingURL=object.js.map

@@ -53,2 +53,9 @@ "use strict";

});
describe('optional()', () => {
it('should return an optional object options object', () => {
const validator = string_1.string();
const options = object_1.optional(validator);
chai_1.expect(options).to.eql({ validator, optional: true });
});
});
//# sourceMappingURL=object.test.js.map
{
"name": "fefe",
"version": "1.0.1",
"version": "1.1.0",
"description": "Validate, sanitize and transform values with proper types.",

@@ -41,14 +41,14 @@ "main": "dist/index.js",

"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.5",
"@types/ramda": "^0.25.45",
"@types/mocha": "^5.2.7",
"@types/ramda": "^0.26.10",
"chai": "^4.2.0",
"codecov": "^3.1.0",
"mocha": "^5.2.0",
"nyc": "^13.1.0",
"codecov": "^3.5.0",
"mocha": "^6.1.4",
"nyc": "^14.1.1",
"ramda": "^0.26.1",
"ts-node": "^7.0.1",
"tslint": "^5.12.0",
"ts-node": "^8.3.0",
"tslint": "^5.18.0",
"tslint-config-standard": "^8.0.1",
"typescript": "^3.2.2"
"typescript": "^3.5.2"
}
}

@@ -9,6 +9,6 @@ # fefe

**πŸ”Ž Validation:** checks a value (example: check if value is string)<br/>
**βš™ Sanitization:** if a value is not valid, try to transform it (example: transform value to `Date`)<br/>
**πŸ› οΈ Transformation:** transforms a value (example: parse JSON)<br/>
**πŸ”Œ Everything is a function**: functional approach makes it easy to extend – just plug in your own function anywhere!
**πŸ”Ž&nbsp;&nbsp;Validation:** checks a value (example: check if value is string)<br/>
**:nut_and_bolt:&nbsp;&nbsp;Sanitization:** if a value is not valid, try to transform it (example: transform value to `Date`)<br/>
**πŸ› οΈ&nbsp;&nbsp;Transformation:** transforms a value (example: parse JSON)<br/>
**πŸ”Œ&nbsp;&nbsp;Everything is a function**: functional approach makes it easy to extend – just plug in your own function anywhere!

@@ -157,3 +157,3 @@ ## Installation

* an object with the following properties:
* `validate`: validator function `(value: unknown) => T`
* `validator`: validator function `(value: unknown) => T`
* `optional?`: allow undefined values (default: `false`)

@@ -160,0 +160,0 @@ * `default?`: default value of type `T` or function `() => T` that returns a default value

@@ -9,3 +9,3 @@ export class ExtendableError extends Error {

export interface FefeChildError {
key: string | number
key: string | number | symbol
error: FefeError

@@ -20,3 +20,3 @@ }

// derived properties
public readonly path: (string | number)[]
public readonly path: (string | number | symbol)[]
public readonly originalError: FefeError

@@ -34,3 +34,3 @@

createParentError (parentValue: any, key: string | number) {
createParentError (parentValue: any, key: string | number | symbol) {
const child: FefeChildError = { key, error: this }

@@ -37,0 +37,0 @@ return new FefeError(parentValue, this.reason, child)

@@ -9,3 +9,3 @@ export { FefeError } from './errors'

export { number } from './number'
export { object } from './object'
export { object, optional } from './object'
export { parseBoolean } from './parse-boolean'

@@ -12,0 +12,0 @@ export { parseDate } from './parse-date'

import { expect } from 'chai'
import { FefeError } from './errors'
import { object } from './object'
import { object, optional, ObjectOptions } from './object'
import { string } from './string'

@@ -60,1 +60,9 @@

})
describe('optional()', () => {
it('should return an optional object options object', () => {
const validator = string()
const options: ObjectOptions<string> = optional(validator)
expect(options).to.eql({ validator, optional: true })
})
})

@@ -40,3 +40,3 @@ import { FefeError } from './errors'

const validated = {} as {[k in keyof D]: ObjectReturnType<D[k]>}
Object.entries(definition).forEach(([key, definitionValue]) => {
Object.entries(definition).forEach(([key, definitionValue]: [keyof D, ObjectDefinitionValue<any>]) => {
const options: ObjectOptions<any> = typeof definitionValue === 'object' ?

@@ -71,1 +71,8 @@ definitionValue :

}
export function optional<R> (validator: Validator<R>): ObjectOptions<R> {
return {
validator,
optional: true
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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