add attribute_before_type_cast

Among other things, this fixes numericality validation. If this looks good, and
it's deemed necessary, I'm happy to add a configuration option which disables
the functionality for people with memory overhead concerns.

See #2137, #2237, #2436, #2429, #2450.