fireproofsocks / dto

Data Transfer Object (DTO) in PHP using JSON Schema
77 stars 12 forks source link

Support for Loose/Strict #7

Closed fireproofsocks closed 8 years ago

fireproofsocks commented 8 years ago

Sometimes you want the "dragnet" functionality: throw anything at the DTO and just keep what sticks (silently fail).

Other times you may want to raise Exceptions when something doesn't map correctly.

One possible solution is to route exceptions to a dedicated method, e.g. handleException... then in a child class, you could re-throw them for a strict implementation.

Alternatively, maybe set something on the root object.

fireproofsocks commented 8 years ago

This has been implemented via the DtoStrict class -- extend it if you want an exception to be thrown if you attempt to write to any non-mapped location, either via the constructor or via any set operation.