Always Valid
Ensures the validity of an object at construction
class Duration {
constructor(private readonly value: number) {
if (this.value < 0) {
throw new Error("value can't be negative");
}
}
}Last updated
Ensures the validity of an object at construction
class Duration {
constructor(private readonly value: number) {
if (this.value < 0) {
throw new Error("value can't be negative");
}
}
}Last updated