validate_data function

Validate data based on specified rules