def update_validated_flags(validated_df, column_name, check):
    """
    Check if the previous_df which is being sent is empty or not.
    If empty set check flag and return the updated raw_df
    :param validated_df: The df containing validated columns and previous flag values.
    :param column_name: The column for which the flag has to be updated.
    :param check: The type of check being performed.
    :return: validation flags updated dataframe
    """
    cond = validated_df[column_name + '_' + check + '_flag'] == 1
    validated_df.loc[cond, column_name + '_' + check + '_flag'
        ] = validated_df.loc[cond, column_name + '_' + check + '_flag'
        ] + validated_df.loc[cond, column_name + '_' + check + '_flag_previous'
        ]
    validated_df.loc[cond, column_name] = validated_df.loc[cond, 
        column_name + '_previous']
    return validated_df
