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.

No comments:

Post a Comment