1.3.0 • Published 11 months ago

fud-ts v1.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

FUD

Fear, uncertainty and doubt (often shortened to FUD) is a propaganda tactic used in sales, marketing, public relations, politics, polling and cults. FUD is generally a strategy to influence perception by disseminating negative and dubious or false information and a manifestation of the appeal to fear.

What?

This package provides a lightweight alternative to zod. You can easily build up runtype types in typescript and validate your unsafe input against those types. You can also derive static typescript types from your runtime types.

Compared to zod, you don't pay for what you don't use: Almost everything is treeshakable.

const personType = object({
    age: number().pipe(isAtLeast(18)),
    name: string(),
    gender: optional(string()),
});

// static type
type Person = TypeOf<typeof personType>;

// parse and validate
const p: Person = personType.parse(input);
console.log(`${p.name} is ${p.age} years old.`);

Source type

The system also tracks the source type to each transformed type.

const dateType = string().pipe(toDate());

// SourceType is 'string'
type SourceType = SourceOf<typeof dateType>;

// TargetType is 'Date'
type TargetType = TypeOf<typeof dateType>;
1.3.0

11 months ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.0

1 year ago