There are many algorithms that generate and validate Canadian SIN numbers. This is the one I use with bean validation. Unlike most other implementations I took into consideration that
8 is not used as the first character in a Canadian SIN. In addition, I utilized a map to deal with the doubled number for the even digits rather than doing the calculation and dealing with greater than 10 results. No regexes are involved either.
Continue reading Canadian SIN Bean Validation plus Generation
StatsCan has posted the rules for what is a valid Canadian postal code:
The postal code is a six-character code defined and maintained by Canada Post Corporation (CPC) for the purpose of sorting and delivering mail. The characters are arranged in the form ‘ANA NAN’, where ‘A’ represents an alphabetic character and ‘N’ represents a numeric character (e.g., K1A 0T6). The postal code uses 18 alphabetic characters and 10 numeric characters. Postal codes do not include the letters D, F, I, O, Q or U, and the first position also does not make use of the letters W or Z.
This post shows how I do the validation using two regular expressions… a strict one and a permissive one combined with Java Bean Validation.
Continue reading Canadian Postal Code Validation
java.util.properties provides a useful way of managing the
.properties files. However, if use the
store() method the order does not get preserved and they add a time stamp resulting in a file that would be harder to put in version control after cleanup.
What I do is use the following code to do my cleanup so the properties are sorted and the time stamp which appears on the first line is removed…
Continue reading Self cleaning Properties
When writing unit tests using Curam, it could be useful to inject some SQL to perform read and writes to the database, especially since the unit test would roll back database changes after the test. The actual JDBC
java.sql.Connection connection object used during the test, can be retrieved using
.getInfo().getInfoConnection() and operations against the database during the transaction can be performed on it.
Continue reading Arbitrary SQL during unit tests
WebSphere Liberty 22.214.171.124 has a bug in the implementation of JASPIC that prevents developers from making their own modules that do not have a user realm that is managed by WebSphere’s UserRegistry. To work around it I took some hints on Arjan Tijms’ work testing with JASPIC on WebSphere Liberty and combined it with my knowledge of Maven and OSGi.
Continue reading WebSphere Liberty NoopUserRegistry Add-On