Refactor type validity checks.
Refactor type validity checks.

No public logic change. The method used internally how supports flags
which can be used to customize check behavior (to be used soon).

cdapio/ui-schema-parser,mtth/avsc,cdapio/ui-schema-parser,cdapio/ui-schema-parser,cdapio/ui-schema-parser,cdapio/ui-schema-parser,mtth/avsc,mtth/avsc,mtth/avsc,mtth/avsc