4.2.0 • Published 6 months ago

@flect/guard v4.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Introduction

Flect/guard is a library for validating that arbitrary JavaScript objects conform to a Flect type.

Usage

const Animal = record({
	legCount: numberType,
	sound: stringType
});
type Animal = Reify<typeof Animal>;

const v = new GuardChain();
const recV = new RecordValidator(v);
v.add(defaultGuards);
v.add(recV);

const maybeAnimal: unknown = {legCount: 3, sound: "woof"};
const animalGuard = v.get(Animal)!;
if (animalGuard(maybeAnimal)) {
	console.log(maybeAnimal.sound); // Goes 'woof'
}
4.2.0

6 months ago

4.1.0

6 months ago

4.0.0

6 months ago

3.0.0

6 months ago

2.4.0

6 months ago

2.3.0

6 months ago

2.2.0

6 months ago

2.1.0

7 months ago

2.0.1

8 months ago

2.0.0

8 months ago

1.2.0

8 months ago

1.1.0

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago