Type cast assigned value before checking for dirty attribute