Review main Merged

70196[FEATURE] Introduce TCA option "min"

Nikita Hovratov CR +2 V +2 Hard +345 −18 updated 08/03/22, 15:56

Commit message

The TCA option "min" allows to define a minimum
number of characters a text field should have. This
effectively adds a "minlength" attribute to the
input field. If you are short on characters, an
alert badge will show you how many characters are
missing. The FormEngine won't allow saving fields
which don't provide enough characters. Zero
characters (empty fields) are allowed, as this is
the same behaviour as the html attribute has. If
empty fields shouldn't be allowed, a combination
with "required=true" is necessary.

This option works for default type="input" fields
and type="text" fields, except if RTE is enabled.

DataHandler will also take care for server-side
validation and reset the value to an empty string,
if "min" is not reached.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Christian Kuhn +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Christian Kuhn +1
    • core-ci +1 CI

Issues 1

Files 17

Review log 5589

Show 3964 earlier messages
  1. Nikita Hovratov uploaded patch set 1 08/03/21, 17:04

  2. core-ci voted on patch set 1 V +1 08/03/21, 17:24 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14055

  3. Anja Leichsenring commented on patch set 1 V -1 08/03/21, 17:57

    I applied the property to an input field and set it to 6. There also is a max property already, I set it to 12. While probably the functionality is correct, the Backend will not give sufficient support to figure out why validation is not true. The messages only care for the max value, leaving me no chance to see whether or not I already exceeded the min requirement.
  4. Andreas Kienast commented on patch set 1 CR -1 08/03/21, 18:00

    It seems the validation is not triggered when creating a new record. I've modified pages.nav_title, but after creating a new record I'd expect a violation for this field as it's empty.

    Feature-92861-IntroduceTCAOptionMin.rst:6

    Please add a new line before this line.
  5. Nikita Hovratov commented on patch set 1 08/03/21, 18:09

    Reply

    Empty fields should not be validated this is correct. See here: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/minlength
  6. Benni Mack commented on patch set 1 08/03/21, 18:27

    Hey Nikita, Just a thought: how about having DataHandler also restrict persisting such records with not enough characters? Also, can we cover cases like "0" or multi-byte characters with tests?
  7. Nikita Hovratov commented on patch set 1 08/05/21, 13:34

    @all Maybe we should first decide, what we want to achieve with this option. My though was to simply introduce the minlength html attribute to FormEngine: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/minlength Meaning empty strings are valid. Similar to range.lower for date types, which means no date provided. As the sibling "max" is not validated in DataHandler as well, I thought "min" shouldn't, too. What would happen, if the DataHandler finds an invalid value? Should it be padded with a certain character? I agree that an indicator would be helpful, to see how many characters are missing. This can look similar to the existing remaining characters indicator for the "max" value.
  8. Nikita Hovratov uploaded patch set 2 08/27/21, 18:02

  9. Nikita Hovratov commented on patch set 2 08/27/21, 18:04

    Reply

    Do you mean if not enough characters were provided, the DataHandler will clear the value?
  10. core-ci voted on patch set 2 V +1 08/27/21, 18:22 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15749

  11. Nikita Hovratov uploaded patch set 3 08/31/21, 13:26

  12. core-ci voted on patch set 3 V +1 08/31/21, 13:41 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15935

  13. Nikita Hovratov uploaded patch set 4 09/02/21, 07:27

  14. core-ci voted on patch set 4 V +1 09/02/21, 07:50 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16048

  15. Nikita Hovratov uploaded patch set 5 09/03/21, 14:47

  16. core-ci voted on patch set 5 V +1 09/03/21, 15:13 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16198

  17. Nikita Hovratov uploaded patch set 6 11/22/21, 16:13

  18. core-ci voted on patch set 6 V -1 11/22/21, 16:31 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19645

  19. core-ci commented on patch set 6 11/22/21, 16:48 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19645

  20. Nikita Hovratov uploaded patch set 7 11/23/21, 13:34

  21. core-ci voted on patch set 7 V -1 11/23/21, 13:52 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19676

  22. Nikita Hovratov uploaded patch set 8 11/24/21, 19:57

  23. core-ci voted on patch set 8 V +1 11/24/21, 20:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19714

  24. Oli Bartsch commented on patch set 8 11/25/21, 21:09

    Reply

    > As the sibling "max" is not validated in DataHandler as well, I thought "min" shouldn't, too. Actually, "max" is checked in DataHandler: https://github.com/TYPO3/typo3/blob/master/typo3/sysext/core/Classes/DataHandling/DataHandler.php#L1699 However, it's not that easy with "min", since adding padding characters is IMO not reasonable. We might just reset the value like it's done for the "eval" checks some lines below?
  25. Nikita Hovratov commented on patch set 8 11/26/21, 08:33

    Reply

    Ah ok, didn't look close enough. Just read the docs for text fields: https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ColumnsConfig/Type/Text/Properties/Max.html?highlight=max#confval-max Let's reset the value then.
  26. Nikita Hovratov uploaded patch set 9 11/26/21, 20:34

  27. Nikita Hovratov commented on patch set 9 11/26/21, 20:34

    Reply

    Done

    Feature-92861-IntroduceTCAOptionMin.rst:6 Reply

    Done
  28. core-ci voted on patch set 9 V -1 11/26/21, 20:47 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19832

  29. Nikita Hovratov uploaded patch set 10 11/26/21, 21:54

  30. core-ci voted on patch set 10 V -1 11/26/21, 22:08 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19840

  31. Nikita Hovratov rebased onto patch set 11 11/27/21, 13:26

  32. core-ci voted on patch set 11 V +1 11/27/21, 13:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19859

  33. Benni Mack wrote 11/29/21, 10:19

    Change destination moved from master to main
  34. Nikita Hovratov updated the commit message in patch set 12 11/29/21, 11:44

  35. core-ci voted on patch set 12 V -1 11/29/21, 11:59 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19973

  36. Nikita Hovratov uploaded patch set 13 12/01/21, 20:11

  37. core-ci voted on patch set 13 V -1 12/01/21, 20:27 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20359

  38. Nikita Hovratov uploaded patch set 14 12/01/21, 20:55

  39. Christoph Schwob wrote 12/01/21, 21:06

    Removed cc Christoph Schwob.
  40. core-ci voted on patch set 14 V -1 12/01/21, 21:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20367

  41. Nikita Hovratov uploaded patch set 15 12/02/21, 08:48

  42. core-ci voted on patch set 15 V +1 12/02/21, 09:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20378

  43. Benni Mack commented on patch set 15 12/10/21, 08:27

    Does this also work for "number"? :)
  44. Nikita Hovratov uploaded patch set 16 12/18/21, 10:44

  45. Nikita Hovratov commented on patch set 16 12/18/21, 10:45

    Reply

    Added a test case for eval=int
  46. core-ci voted on patch set 16 V -1 12/18/21, 10:55 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21233

  47. Nikita Hovratov uploaded patch set 17 12/18/21, 11:01

  48. core-ci voted on patch set 17 V +1 12/18/21, 11:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21234

  49. Nikita Hovratov uploaded patch set 18 01/14/22, 19:02

  50. Nikita Hovratov uploaded patch set 19 01/14/22, 19:13

  51. Nikita Hovratov uploaded patch set 20 01/14/22, 19:17

  52. core-ci voted on patch set 20 V +1 01/14/22, 19:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22088

  53. Nikita Hovratov uploaded patch set 21 01/17/22, 17:38

  54. core-ci voted on patch set 21 V +1 01/17/22, 17:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22188

  55. Nikita Hovratov uploaded patch set 22 01/22/22, 20:56

  56. core-ci voted on patch set 22 V +1 01/22/22, 21:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22412

  57. Nikita Hovratov uploaded patch set 23 02/12/22, 10:24

  58. core-ci voted on patch set 23 V -1 02/12/22, 10:40 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23442

  59. Nikita Hovratov uploaded patch set 24 02/12/22, 16:42

  60. core-ci voted on patch set 24 V +1 02/12/22, 16:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23462

  61. Nikita Hovratov uploaded patch set 25 02/18/22, 18:42

  62. core-ci voted on patch set 25 V +1 02/18/22, 18:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23889

  63. Nikita Hovratov uploaded patch set 26 03/24/22, 16:49

  64. core-ci voted on patch set 26 V -1 03/24/22, 17:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25103

  1. Nikita Hovratov uploaded patch set 27 03/24/22, 17:16

  2. core-ci voted on patch set 27 V +1 03/24/22, 17:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25108

  3. Nikita Hovratov uploaded patch set 28 04/08/22, 21:20

  4. Nikita Hovratov uploaded patch set 29 04/08/22, 21:23

  5. core-ci voted on patch set 28 V -1 04/08/22, 21:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25866

  6. core-ci voted on patch set 29 V +1 04/08/22, 21:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25868

  7. Nikita Hovratov uploaded patch set 30 04/19/22, 12:35

  8. core-ci voted on patch set 30 V +1 04/19/22, 12:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26185

  9. Simon Schaufelberger uploaded patch set 31 06/10/22, 11:41

  10. core-ci voted on patch set 31 V +1 06/10/22, 11:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27916

  11. Simon Schaufelberger uploaded patch set 32 07/07/22, 01:36

  12. core-ci voted on patch set 32 V +1 07/07/22, 01:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/28697

  13. Nikita Hovratov commented on patch set 32 07/07/22, 07:09

    Thanks for rebasing!
  14. Anja Leichsenring uploaded patch set 33 08/02/22, 08:57

  15. Anja Leichsenring commented on patch set 33 V -1 08/02/22, 09:00

    The invalid badge does not look good yet, might be I messed up the rebase. When you activate the test_datahandler extension in a test environment and create a new tt_content record, you can see what happens if you start typing into one of the new fields. Additionally, if I save the record right away, without activating the JS function for the count, I can do that. I am not sure this is expected behavior, but when you define a min value, empty should not be valid IMO.
  16. core-ci voted on patch set 33 V -1 08/02/22, 09:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29776

  17. Anja Leichsenring uploaded patch set 34 08/02/22, 10:07

  18. Anja Leichsenring commented on patch set 34 V -1 08/02/22, 10:08

    comment still applies, I only fixed failing pipeline jobs. https://review.typo3.org/c/Packages/TYPO3.CMS/+/70196/comments/24565bdb_85dea9db
  19. core-ci voted on patch set 34 V +1 08/02/22, 10:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29778

  20. Nikita Hovratov uploaded patch set 35 08/02/22, 13:03

  21. core-ci voted on patch set 35 V +1 08/02/22, 13:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29784

  22. Nikita Hovratov commented on patch set 35 08/02/22, 13:12

    Reply

    Thanks for your review, yes the badge had old bootstrap classes I updated them now. For this min feature, empty values are valid as it should work exactly like for the html attribute "minlength". See: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/minlength

    Reply

    It is fixed already, I think you checked an old patchset.
  23. Christian Kuhn voted on patch set 35 V +1 CR +1 08/02/22, 14:18

  24. Stefan Bürk voted on patch set 35 V +2 CR +2 08/03/22, 15:56

  25. Stefan Bürk merged patch set 36 08/03/22, 15:56