-- Andreas Möller <[email protected]> wrote (on Friday, 17 February 2012, 08:47 AM +0100): > I've got an application where dates need to be validated, but the > exactness of the dates varies. > > Sometimes > > * only year (4 digits) > * only year (4 digits) and month (2 digits) > * only year (4 digits), month (2 digits) and day of month (2 digits) > * etc > > is required. > > Is it possible to tell Zend_Validate_Date / Zend_Date that for the > given input and locale I require a combination of parts of a date (as > above) without having to specify formats for every locale - in short, > I need these parts, here is the locale, now validate? > > Examples (en_US) > * 2012 > * 2012/02 > * 2012/02/17 > > Examples (de_DE) > * 2012 > * 02/2012 > * 17.02.2017
TBH, I'd build a custom validator for this. The date validator as it currently stands checks to ensure the provided date is valid -- and as such needs the full date. What you're describing is a very specific strategy that allows for multiple specifications, dependent on locale. Within your validator, I'd determine what segments I had, and then add data to them in order to validate them against Zend_Validate_Date -- so, for instance, if you got just the year, add month 01 and day 01, and validate; if you go the year and month, add day 01 and validate; otherwise, validate the entire date. -- Matthew Weier O'Phinney Project Lead | [email protected] Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc -- List: [email protected] Info: http://framework.zend.com/archives Unsubscribe: [email protected]
