beberlei/assert — pull request #56 by brianpilati (2014-03-27 18:58:28+00:00)
Title: Added a currency assertion and tests

Thanks for creating and sharing such a useful and verbose library with the community.

Currency
------------

I have a need for a currency assertion ... and it quickly spiraled. ;) I wanted to be "international aware" and hopefully covered some bases between different monetary symbols, prefixes and suffixes of different currencies and countries. However, I am no expert on International monetary standards based on my one trip and PBS viewing. From my research ... the tests pass.

The Assertion Method:
------------------------------
```
currency($value, $locale = 'en_US', $message = null, $propertyPath = null)
```

The locale follows the i18n/setlocale character sets. I did not key off of the php.ini set_locale variable with the thoughts that consumers might want to validate a currency regardless of their own locale. Use case: an Italian company validates currencies from around the world.

Feedback and Comments Requested:
--------------------------------------------------
I struggled with requiring monetary symbols, spaces and cents. I finally decided to make symbols and spaces optional and require cents (decimals). Example: $1.00, $ 1.00 and 1.00 are acceptable. However $1, $ 1, 1 and 1.0 are not acceptable.

I extended the decimals to 4 places for monetary institutions.

I went with a straight forward - (negative sign) for negative values and did not divide into accounting practices with <> (angle brackets) denoting negative amounts.

I followed the current coding pattern in the lib/Assert/Assertion.php and test/Assert/Tests/AssertTests.php to the best of my ability. Caveat -- validating monetary symbols, prefixes and suffixes introduced complexity into the assertion method that does not exist in other methods. I am open to suggestions on how to improve the readability of the method.

Examples of Acceptable Formats
--------------------------------------------

#### en_US
```
1.00
$1.00
$ 1.00
$-1.00
$1.125
$1,100,100.1250
```

#### de_DE
```
1,00
1,00€
1,00 €
-1,00€
1,125€
1.100.100,125€
```

#### it_IT
```
1,00
€1,00
€ 1,00
€-1,00
€1,125
€1.100.100,125
```

3rd Party Validation
--------------------------
* The pull-request built and the tests passed using drone.io.
* No issues regarding my code were detected using scrutinizer-ci.com.

HouseKeeping
--------------------
Add the currency assertion to the README file. I noticed missing assertions and lack of alphabetization. I have fixed both issues.

Cheers,
Brian