Creating a ValueObject
Steps to create a ValueObject
Declare your class this way :
Add the imports and part statements, the @Modddel
annotation, and the private empty constructor.
Add the factory constructor :
Create your failure(s) sealed class(es).
You can now run the generator, and then override and implement the "validate" methods.
Default validationSteps names
The name
parameter of the ValidationStep is optional. If you omit it, it will be replaced by a default name :
Step | Default name | Example |
---|---|---|
1 | Value1 | InvalidAgeValue1 |
2 | Value2 | InvalidAgeValue2 |
3 | Value3 | InvalidAgeValue3 |
... | ... | ... |
If there's only one step, then its default name is 'Value' (instead of 'Value1').
Complete Example
![](https://docs.modddels.dev/~gitbook/image?url=https%3A%2F%2F1717630883-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fqwvgw6ljtlFnt8j8qA3V%252Fuploads%252FkclInDIZlN31JUZrnlRM%252Fimage.png%3Falt%3Dmedia%26token%3D17db7bed-ca8d-40ff-ad27-e4cfb2fff088&width=768&dpr=4&quality=100&sign=c69c9bcb&sv=1)
Last updated