@borisbelmar/value-object
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

ValueObject

Abstract ValueObject class for DDD apps. It includes validation.

Quick start

export interface UniqueIdProps {
  id: string
}

export default class UniqueId extends ValueObject<string> {
  static create (props: UniqueIdProps): UniqueId {
    const validator = new ValueObjectValidator(props.id, UniqueId.name)
    validator.required().string().uuid()
    return new UniqueId(props.id)
  }
}

Coming features

  • [ ] Tests
  • [x] Regex string validation
  • [ ] Custom validations
  • [ ] Improve documentation

Package Sidebar

Install

npm i @borisbelmar/value-object

Weekly Downloads

0

Version

1.4.0

License

ISC

Unpacked Size

37.2 kB

Total Files

57

Last publish

Collaborators

  • borisbelmar