Fix patternProperties bugs and do validation on the pattern regex. Add new unit tests.

This commit fixes issues with patternProperties that caused it to not work properly, failing on properties that satisfied the pattern regex. The patternProperties regex is validated using preg_match(). Now, patternProperties works correctly. New unit tests for positive and negative cases have been added to verify the changes.