Review main Merged

64940[FEATURE] Provide custom error messages in RegularExpressionValidator

Mohsin Khan CR +2 V +2 Normal +210 −14 updated 10/19/20, 18:11

Commit message

Add the possibility to provide custom Error messages to the
RegularExpressionValidator. In some cases the default message will
not suffice in supporting the user to fill in a valid value. It is now
possible to equip a validator with static or translatable messages,
like e.g. "Invalid Mobile Phone Number Format".

Review

  • Code review CR +2 Done
    • Anja Leichsenring +2
    • Christian Kuhn +1
  • Verified V +2 Done
    • Anja Leichsenring +2
    • Christian Kuhn +1
    • TYPO3com +1 CI

Issues 1

Files 4

Review log 3854

Show 2129 earlier messages
  1. Mohsin Khan uploaded patch set 1 06/26/20, 16:54

  2. TYPO3com voted on patch set 1 V +1 06/26/20, 17:05 Completed build in 11m 33s on Fri, 26 Jun, 05:05 PM Test Summary: 72863 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3990

  3. Anja Leichsenring uploaded patch set 2 06/28/20, 06:58

  4. TYPO3com voted on patch set 2 V -1 06/28/20, 06:58 Completed build in 36s on Sun, 28 Jun, 06:58 AM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3994

  5. Anja Leichsenring uploaded patch set 3 06/28/20, 07:10

  6. TYPO3com voted on patch set 3 V -1 06/28/20, 07:11 Completed build in 23s on Sun, 28 Jun, 07:11 AM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3995

  7. Anja Leichsenring uploaded patch set 4 06/28/20, 07:12

  8. TYPO3com voted on patch set 4 V +1 06/28/20, 07:24 Completed build in 11m 53s on Sun, 28 Jun, 07:24 AM Test Summary: 72869 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-3996

  9. Anja Leichsenring voted on patch set 4 V +1 CR +1 06/28/20, 08:46

  10. Willi Wehmeier voted on patch set 4 CR +1 06/28/20, 12:58

  11. Markus Klein commented on patch set 4 06/29/20, 07:29

    IMO this solution is missing a possibility to deliver a translatable error message. Providing a static message in an PHP-annotation is not so helpful for achieving this.
  12. Christoph Lehmann commented on patch set 4 06/29/20, 11:12

    RegularExpressionValidator.php:44 Unresolved

    Nice feature! When you use $this->translateErrorMessage( $this->options['errorMessage'], '' ), you could use something like 'LLL:EXT:your-ext/path-to-your-errormessage' to have a translatable error message
  13. Anja Leichsenring uploaded patch set 5 06/29/20, 16:24

  14. TYPO3com voted on patch set 5 V -1 06/29/20, 16:25 Completed build in 28s on Mon, 29 Jun, 04:25 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4007

  15. Anja Leichsenring uploaded patch set 6 06/29/20, 16:33

  16. Anja Leichsenring uploaded patch set 7 06/29/20, 16:40

  17. TYPO3com voted on patch set 6 V -1 06/29/20, 16:47 Completed build in 13m 59s on Mon, 29 Jun, 04:47 PM Test Summary: 62253 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4008

  18. Anja Leichsenring commented on patch set 7 06/29/20, 16:52

    now also with translation support. I fiddled with the code too much, no vote from me anymore.
  19. TYPO3com voted on patch set 7 V +1 06/29/20, 16:55 Completed build in 15m 01s on Mon, 29 Jun, 04:55 PM Test Summary: 72881 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4009

  20. Markus Klein updated the commit message in patch set 8 06/29/20, 16:56

  21. Daniel Goerz commented on patch set 8 06/29/20, 17:00

    RegularExpressionValidator.php:71 Unresolved

    This can be return $errorMessage ?? '';
  22. Markus Klein commented on patch set 8 CR -1 06/29/20, 17:01

    on it

    Feature-91719-CustomErrorMessagesInRegularExpressionValidator.rst:24

    I suggest "MyModel" here as classname for clarity.

    RegularExpressionValidator.php:58

    is the array key always set? otherwise ?? operator is needed here.

    RegularExpressionValidator.php:62

    simply use $this->translateErrorMessage() here too?
  23. Anja Leichsenring updated the commit message in patch set 9 06/29/20, 17:02

  24. Anja Leichsenring commented on patch set 9 06/29/20, 17:04

    Feature-91719-CustomErrorMessagesInRegularExpressionValidator.rst:24 Reply

    Ack

    RegularExpressionValidator.php:58 Reply

    Ack

    RegularExpressionValidator.php:62 Reply

    this will not work, as the method will always add the extbase extension as source of translation labels.
  25. Anja Leichsenring uploaded patch set 10 06/29/20, 17:05

  26. Anja Leichsenring uploaded patch set 11 06/29/20, 17:09

  27. TYPO3com voted on patch set 8 V +1 06/29/20, 17:14 Completed build in 16m 38s on Mon, 29 Jun, 05:14 PM Test Summary: 72881 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4011

  28. Markus Klein commented on patch set 11 06/29/20, 17:14

    RegularExpressionValidator.php:62 Reply Unresolved

    Well, if string is LLL then this does not matter
  29. Markus Klein commented on patch set 11 CR -1 06/29/20, 17:15

    on it
  1. Markus Klein uploaded patch set 12 06/29/20, 17:18

  2. TYPO3com voted on patch set 12 V -1 06/29/20, 17:23 Completed build in 35s on Mon, 29 Jun, 05:23 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4015

  3. Daniel Goerz commented on patch set 12 CR -1 06/29/20, 17:25

    RegularExpressionValidator.php:59

    This changes the default now. If the option is not set, an empty string is returned.
  4. Markus Klein commented on patch set 12 06/29/20, 17:26

    RegularExpressionValidator.php:59 Reply Unresolved

    right, I accidentally removed the if ($errorMessage && part before I pushed. So we need a test, covering this ;-)
  5. TYPO3com voted on patch set 9 V +1 06/29/20, 17:28 Completed build in 19m 56s on Mon, 29 Jun, 05:28 PM Test Summary: 72881 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4012

  6. TYPO3com voted on patch set 10 V +1 06/29/20, 17:28 Completed build in 20m 08s on Mon, 29 Jun, 05:28 PM Test Summary: 72881 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4013

  7. Markus Klein uploaded patch set 13 06/29/20, 17:30

  8. TYPO3com voted on patch set 11 V +1 06/29/20, 17:34 Completed build in 17m 00s on Mon, 29 Jun, 05:34 PM Test Summary: 72881 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4014

  9. Anja Leichsenring commented on patch set 13 06/29/20, 17:34

    RegularExpressionValidatorTest.php:88

    I created functional tests for the part where translation is involved. I guess this would be a better fit than using a mock as system under test.
  10. TYPO3com voted on patch set 13 V -1 06/29/20, 17:46 Completed build in 15m 57s on Mon, 29 Jun, 05:46 PM Test Summary: 12 of 72920 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4016

  11. Markus Klein commented on patch set 13 06/29/20, 17:48

    RegularExpressionValidatorTest.php:88 Reply Unresolved

    My thought was more: Lets keep the overhead small. the translateErrorMessage function is only a wrapper around a static utility, so lets remove that one. So, I do not consider this "mock the system under test". Of course feel free to adjust this. No hard feelings. ;-)
  12. Markus Klein commented on patch set 13 06/29/20, 17:51

    will fix the broken tests first
  13. Markus Klein uploaded patch set 14 06/29/20, 17:56

  14. TYPO3com voted on patch set 14 V +1 06/29/20, 18:11 Completed build in 15m 23s on Mon, 29 Jun, 06:11 PM Test Summary: 72893 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4018

  15. Anja Leichsenring commented on patch set 14 V +1 CR +1 06/29/20, 18:13

    I think we got a double test coverage now :) Once unit, once functional tests. Should be sufficient.
  16. Daniel Goerz commented on patch set 15 06/29/20, 18:20

    Published edit on patch set 14.
  17. Anja Leichsenring voted on patch set 15 V +1 CR +1 06/29/20, 18:32

  18. TYPO3com voted on patch set 15 V -1 06/29/20, 18:34 Completed build in 13m 23s on Mon, 29 Jun, 06:34 PM Test Summary: 1 of 73380 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4020

  19. TYPO3com voted on patch set 15 V +1 06/29/20, 18:41 Completed build in 34m 01s on Mon, 29 Jun, 06:41 PM Test Summary: 72893 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-4020

  20. Daniel Goerz commented on patch set 15 06/29/20, 19:03

    Wouldn't this be a welcome feature for ALL validators?
  21. Christoph Lehmann commented on patch set 15 10/18/20, 00:46

    Some of them have multiple error messages, so a custom error message makes no sense to me because which one to override? Most of them have translatable error messages. The regular expression validator is special because you can have it multiple times checking different regexps and thus needs different error messages.
  22. Christian Kuhn voted on patch set 15 V +2 CR +2 10/19/20, 18:11

  23. Christian Kuhn voted on patch set 15 V +1 CR +1 10/19/20, 18:11

  24. Anja Leichsenring voted on patch set 15 V +2 CR +2 10/19/20, 18:11

  25. Anja Leichsenring merged patch set 16 10/19/20, 18:11