The function validate_from_file should read a YAML file from the specified path and validate that it contains all required fields. Here's a breakdown of its expected behavior:
Functionality: The function takes a single parameter, yaml_file, which should be the path to a YAML file. If the file is not provided or does not exist, an IRValidatorException should be raised with an appropriate error message. If the file exists, its contents are read, and the content is validated for required fields using a separate method validate_from_content. If the validation succeeds, the function returns the loaded content as a dictionary.
Expected Input/Output Behavior:
Input: A valid file path as a string to a YAML file that adheres to the expected schema.
Output: A dictionary containing the data from the YAML file if all required fields are present.
Exceptions: Raise IRValidatorException if:
yaml_file is None
The path does not point to an existing file
Required fields are missing in the file content (handled by validate_from_content).
Edge Cases:
Provide no path (None).
Provide an invalid path that does not exist.
Provide a YAML file that lacks mandatory fields necessitated by the validate_from_content method.
Note: The solution should be placed in /app/solution.py.
The function must be importable as: from solution import validate_from_file.