CoreCommunity ExtensionsIncubatorDistributionsTYPO3 4.5 ProjectsTYPO3 4.6 ProjectsTYPO3 4.7 ProjectsTYPO3 6.0 ProjectsTYPO3 6.1 ProjectsTYPO3 6.2 Projects (+)

Feature #35149

Add "isFullAge"-ErrorCheck

Added by Alexander Pankow about 1 year ago. Updated 6 months ago.

Status:Resolved Start date:2012-03-22
Priority:Should have Due date:
Assignee:Reinhard Führicht % Done:

100%

Category:Error checks
Target version:v1.5.0
Votes: 2 (View)

Description

In my opinion, it makes sense to add a error-check to check if a entered date is full-aged or not.
I know that this can be realized with the DateRange-ErrorCheck, but it is very complex.
So i've realized a ErrorCheck what does it for me. You can find the file attached.

Here's sample TypoScript Code:

birthdate.errorCheck {
    1 = required
    2 = date
    2.pattern = dd.mm.yyyy
    3 = isFullAge
    3 {
        pattern = dd.mm.yyyy
        years = 18
        inverted = 1
    }
}

Explanation for the options i've implemented:
  • pattern: I think, further description isn't required (mandatory)
  • years: Here you can define the years to be a full-aged person. (mandatory)
  • inverted: If this option is set to true, it is possible to check if a person is NOT full-aged (the option-name is maybe not the best, but i have no other ideas ...)

Tx_Formhandler_ErrorCheck_IsFullAge.php (3.1 kB) Alexander Pankow, 2012-03-22 15:27

35149.patch (12.2 kB) Reinhard Führicht, 2012-11-29 19:47

Associated revisions

Revision 68649
Added by Reinhard Führicht 6 months ago

2 new error checks "isOlderThan", "isYoungerThan" (resolves #35149)

Revision 68649
Added by Reinhard Führicht 6 months ago

2 new error checks "isOlderThan", "isYoungerThan" (resolves #35149)

History

Updated by Reinhard Führicht 6 months ago

  • File 35149.patch added
  • Status changed from New to Needs Feedback
  • Assignee set to Reinhard Führicht
  • Target version set to v1.5.0
  • % Done changed from 0 to 80

After a really long time I was in the mood today to try to create a patch for this.

As I thought, it turned out to be more difficult than it seemed, as always when dealing with date related stuff. :-)

I attached a patch, which adds 2 new error checks "isOlderThan" and "isYoungerThan".
Furthermore, I had to rewrite some lines in Finisher_DB and the backend module to make them reuse some code and move the date to timestamp conversion to the utility funcs.

I tested it with this basic setup:

validators {
    1.class = Validator_Default
    1.config.fieldConf {

        age.errorCheck.1 = required
        age.errorCheck.2 = isOlderThan
        age.errorCheck.2 {
            dateFormat = d.m.Y
            years = 10
        }
        age.errorCheck.3 = isYoungerThan
        age.errorCheck.3 {
            dateFormat = d.m.Y
            years = 20
        }
    }
}

finishers {
    5 {
        class = Finisher_DB
        config {
            table = tt_address
            fields {
                pid = 56
                city.special = date
                city.special {
                    dateFormat = d.m.Y
                    field = age
                }
                zip.special = datetime
                zip.special {
                    dateFormat = d.m.Y H:i
                    field = starttime
                }
            }
        }
    }
}

It would be nice to get additional feedback and test results before committing it to trunk.

Updated by Reinhard Führicht 6 months ago

  • Status changed from Needs Feedback to Resolved
  • % Done changed from 80 to 100

Applied in changeset r68649.

Also available in: Atom PDF