Enforce data type on model assignment

What is the best way to in Yii enforce the data type at input-level to a model? I have learned that the validators in Yii are not enough to enforce a data type as they only say yes or no to if the datatype is right. All other subsequent code will still need to handle that the assigned variables can contain any type of data.

Before I started with Yii, I used to have helper-functions for reading primitive data types from GET/POST/array etc. Those would take the variable to get but also a type to enforce (int, double, bool, string etc.) In case the data is unavailable or not possible/suitable to convert to the right type, the function would return null.

My guess in the MVC world and Yii, the best would be to enforce the input data type at the model level or maybe at controller level but not at the view level. Does there exist any good framework for this in yii? perhaps there is a method in models to override that is called on assignment. Or should I write a new type enforcement validator that also enforce the data type?

Or is the "proper" way to do this to enforce data type "manually" in the actions of the controllers? Eg. after doing a multi-assigment, do eg.

$model->attributes = $_POST[‘User’];

$model->name = EnforceStringOrNull($model->name);

$model->age = EnforceIntOrNull($model->age);

I think a drawback with this is that when you modify a model, it is easy to forget to update the controller(s) as well.