dddshelf / ddd-in-php-book-issues

Leave your comments, improvements or book mistakes as an issue! Thanks ❤️
https://leanpub.com/ddd-in-php
28 stars 2 forks source link

Silex controller / Form parameters validation #88

Open mcrio opened 5 years ago

mcrio commented 5 years ago

Hi, in the Application > Request part of the book there is an example about using Silex to validate the form and proceed with user signup:

    // On a more elaborate Silex application that uses the Form 
    // component to capture and validate parameters, it would look like this:

    $app->match('/signup', function (Request $request) use ($app) {
    $form = $app['sign_up_form'];
    $form->handleRequest($request);

    if ($form->isValid()) {
        $data = $form->getData();
.....

As I understand you might be configuring additional validation rules for the Silex Form like validating email etc., and that those rules might be a copy of how the same data is validated in the domain model, which is probably hard to maintain?