title

fire chief's random developer tidbits

Monday, November 8, 2010

Value 'blah' is not facet-valid with respect to pattern 'meh'

I haven't done much with XSD, but I'm fixing an application that validates its (overly complex) xml config file against an XSD.


It reads in a database host address and validates it with a regex.  I needed to add a port config entry so it looked simple enough.  I just wanted to validate that the port is 1 to 5 digits and don't want to limit it to actual port ranges.  It's just a simple validation to help catch typos.  So I whipped up a regex "^\d{1,5}$".


Then I got the error "Value '3307' is not facet-valid with respect to pattern '^\d{1,5}$'".  What does this mean? Well, I ran across this page which says "Particularly noteworthy is the complete absence of anchors like the caret and dollar."  So I took out my caret and dollar and then the validation worked.

What this blog isn't

This blog isn't a place to put pictures of my kids.
This blog isn't a place for me to be a pundit.
This blog isn't a place for me to show off.
This blog isn't a place for innane product tie-ins, just to get google ad revenue.

It's just me, solving problems with Java and posting the particularly strange ones where the solution wasn't collected in a single place already.

Maybe it will evolve to more than that, but don't hold your breath.