Zend Framework: Zend_Filter_Boolean Component Proposal
| Proposed Component Name | Zend_Filter_Boolean |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_Filter_Boolean |
| Proposers | Thomas Weidner |
| Zend Liaison | TBD |
| Revision | 1.0 - 12 April 2009: Initial Draft. (wiki revision: 8) |
Table of Contents
1. Overview
Zend_Filter_Boolean is a additional filter which allows to filter boolean words, also localized once, to a boolean value.
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
- This component will convert given values to a boolean
- This component will allow the usage of localized yes/no strings
- This component will allow to usage of "yes" or "no"
4. Dependencies on Other Framework Components
- Zend_Exception
- Zend_Filter
- Zend_Locale
5. Theory of Operation
This filter will convert given input to boolean. This will not only cast values to boolean, but also allow to use string representations like "yes" or "no" as also their localized represenation like "Ja" or "Si" and have them returned as boolean to work with them for example within a database.
6. Milestones / Tasks
- Milestone 1: [DONE] Proposal finished
- Milestone 2: [DONE] Proposal accepted
- Milestone 3: [DONE] Working implementation
- Milestone 4: [DONE] Unit tests
- Milestone 5: [DONE] Documentation
- Milestone 6: [DONE] Moved to core
7. Class Index
- Zend_Filter_Boolean
8. Use Cases
| UC-01 |
|---|
working with different types
| UC-02 |
|---|
Localized recognition, note that english is always recognised
| UC-03 |
|---|
Localized recognition by setting the locale afterwards
9. Class Skeletons
Labels:
None
6 Comments
comments.show.hideApr 28, 2009
Marc Hodgins
This is a great idea.
Jul 14, 2009
Matthew Weier O'Phinney
This proposal is approved for immediate development in the standard incubator, with the following conditions:
Aug 29, 2009
Eric Coker
I mistakenly missed this proposal when submitting my own for a boolean filter.
Firstly, I suggest renaming to Zend_Filter_Bool for naming consistency with Zend_Filter_Int.
Below is modified text from the "theory of operation" from my proposal. I think it is important to roll the following functionality into your version, which primarily addresses only localization issues. Additionally, I hope the below will argue the case for not conforming to the way that PHP casting works:
The (bool) and (boolean) casts in PHP consider NULL and empty strings to be
FALSE, and any value that is not specifically FALSE to be TRUE. When filtering data from forms or databases, such assumptions are likely to result in logic errors.
A different set of needs is addressed by filtering as opposed to casting to boolean:
The following values should be considered FALSE:
The following values should be considered TRUE:
The filter should output NULL upon attempting to process any value not listed above.
Aug 29, 2009
Thomas Weidner
No for the renaming...
As you can read (http://framework.zend.com/wiki/display/ZFPROP/Naming+conventions+for+2.0+-+Matthew+Ratzloff) abbreviations are depreciated for components.
Zend_Validate_Int will be renamed to Zend_Validate_Integer as with ZF 2.0.
Therefor we will not add new abbreviations as preparation for 2.0.
I will comment the other suggestions as soon as I begin to work on this component in detail.
Nov 24, 2009
Ben Scholzen
I suppose you are going to use the yes/no strings from Zend_Locale_Data? See for example at the bottom of:
http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Locale/Data/de.xml
Nov 24, 2009
Thomas Weidner
I don't get the point of your question...
The proposal states:
And the implementation within incubator already has this feature available.