Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/util #31

Merged
merged 12 commits into from
Jan 20, 2023
Merged

Feat/util #31

merged 12 commits into from
Jan 20, 2023

Conversation

4lessandrodev
Copy link
Owner

1.16.2 - 2022-01-19

Added

  • 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);
  }

}

@4lessandrodev 4lessandrodev added the enhancement New feature or request label Jan 20, 2023
@4lessandrodev 4lessandrodev merged commit f4cbd05 into main Jan 20, 2023
@4lessandrodev 4lessandrodev deleted the feat/util branch January 20, 2023 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant