initial commit
This commit is contained in:
commit
0db3e92ee6
59 changed files with 3384 additions and 0 deletions
27
readme.md
Normal file
27
readme.md
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Assessment: VeruA DomainObjects & Validation
|
||||
The following assessment may be solved with the help of additional sources, such as Q&A or LLMs but must be indicated as such.
|
||||
|
||||
## General
|
||||
In the example `index.php` there are three DomainObjects that are instantiated with default values. An [Owner](https://docs.verua.ch/latest/classes/VeruA-DomainObjects-Owner.html)-Object and a [Client](https://docs.verua.ch/latest/classes/VeruA-DomainObjects-Client.html)-Object are build directly. The third, an [Address](https://docs.verua.ch/latest/classes/VeruA-DomainObjects-Address.html)-Object is passed into the address field of the `Client`-Object.
|
||||
|
||||
All three are then validated acording to their respective validators. The Address object is validated through the [ClientValidator](https://code.verua.online/VeruA/Assessment/src/commit/83166a50af0cca2873d74ae0955cad67d20a5d02/src/DomainObjects/Validation/ClientValidator.php#L24).
|
||||
|
||||
## Exercises
|
||||
|
||||
1. Find out where and when the *default validators* of a `ValueObject` are executed.
|
||||
|
||||
1. A *default validator* has to check that an e-mail address is correct on the `email` field of `Owner` and of `Client::Address` if set, but the field can be empty.
|
||||
Implement it in the `ValueObjects/Email` class and use php's [filter_var(FILTER_VALIDATE_EMAIL)](https://www.php.net/manual/en/filter.constants.php#constant.filter-validate-email)
|
||||
|
||||
1. The validation works well, but the requirements changed. Redesign it, to implement the possibility to have multiple validators at once. As an example implement a new `ExportAddressValidator` in addition to the standard `AddressValidator` that requires an e-mail address and a valid AHV-number. The goal is, to check, if a given `DomainObject` is valid against different validators in different circumstances, configured and executed in one run.
|
||||
|
||||
1. `DomainObjects` are often loaded from a database with the *DataMapper Pattern*, where you get entire collections of `DomainObjects` containing more child objects.
|
||||
E.g. you have a collection of `Invoice`-Objects that contains an `Owner`-Object, a `Client`-Object that in turn contains an `Address`-Object.
|
||||
We need a possibility to preconfigure the validators that have to be used to validate the whole collection of `DomainObjects`
|
||||
This excecise is about the design decisions and not the code. Feel free to design with UML, sample code or with whatever you feel the most comfortable.
|
||||
|
||||
## Considerations
|
||||
|
||||
- Rewrite it with the possibility to have different Validators from different packages.
|
||||
|
||||
- Keep in mind, that if a field is not set at all, it is never validated.
|
||||
Loading…
Add table
Add a link
Reference in a new issue