Here's a patch that implements this. The current test suite tests it some, but we should probably add more tests. I also patched a few schemas that it found to be in error.
The validity checking itself is straightforward. Enabling and disabling it is not.
Doing it at parse time isn't good enough, since schemas are often created directly with the Schema API (e.g., IDL & builder). So the check needs to be in the Field constructor. But then to be able to turn checking on and off we need a global flag (yuk) that the constructor reads.
The existing name validation uses a ThreadLocal<Boolean> as such a global flag. Schema.Parser sets this around calls to parse(). By default name validation is on and is disabled when parsing schemas from data files.
For default values, we want validation off by default. I used the same ThreadLocal mechanism to permit Schema.Parser to enable or disable it. As with name validation, I added no mechanism to enable checking outside of Schema.Parser.
However I think we should do something by default to let folks know there's a problem with their schema. Throwing an exception would break lots of existing users. Logging a warning might be appropriate. The avro core module however doesn't currently have a logging dependency, and we shouldn't add one here. So this patch prints warnings to System.err. Does that seem reasonable?