0.3.6 • Published 5 years ago
@vapurrmaid/validate v0.3.6
Validate
An incredibly simple, zero-dependency package for writing maintainable, easy-to-read, validation assertions. This package is highly inspired by:
- The Java package org.apache.commons.lang3.Validate and its use in the DDD community
- BDD-style assertions used in
Jest
andchai
Usage of Validate
is an opinionated, stylistic preference. Other options exists - see the example
usage to get a feel for how Validate
can improve code style.
Example Usage
Without:
class PositiveNumber {
public readonly value: number;
constructor(i: number) {
if (i <= 0) {
throw new Error(`i must be greater than 0. Instead received ${i}`);
}
this.value = i;
}
}
With:
import { Validate } from '@vapurrmaid/validate';
class PositiveNumber {
public readonly value: number;
constructor(i: number) {
Validate.isTrue(i > 0, `i must be greater than 0. Instead received ${i}`);
this.value = i;
}
}
1.0.0-beta.0
5 years ago
0.3.6
5 years ago
0.3.5
5 years ago
0.3.4
5 years ago
0.3.3
5 years ago
0.3.2
5 years ago
0.3.1
5 years ago
0.3.0
5 years ago
0.3.0-beta.1
5 years ago
0.3.0-beta.0
5 years ago
0.2.1
5 years ago
0.2.0
6 years ago
0.1.0
6 years ago
0.1.1
6 years ago
0.1.0-beta.2
6 years ago
0.1.0-beta.1
6 years ago
0.1.0-beta.0
6 years ago