Add file extension validation to types.file().

Requires testing and documentation.