Aggregate, Entity, ValueObject: added util method to instance.
Util: added class to domain with some utils functions.
Example:
// remove spaces from string
const text = " Some Text With Space ";
const result = Utils.string(text).removeSpaces();
> "SomeTextWithSpace"
// remove special chars
const text = "Some #Text @With Special&* Chars";
const result = Utils.string(text).removeSpecialChars();
> "Some Text With Special Chars"
// calculate values as number
const result = Utils.number(100).multiplyBy(3);
> 300
// also works case leak value as string
const result = Utils.number("100").multiplyBy("3");
> 300
// instance available on domain instances
interface Props { value: number };
class Example extends ValueObject<Props>{
private constructor(props: Props){
super(props)
}
sum(x: number): number {
const current = this.props.value;
return this.util.number(current).sum(x);
}
}
1.16.2 - 2022-01-19
Added
util
method to instance.Example: