deirokay.validator.validate
- deirokay.validator.validate(df: DeirokayDataSource, *, against: Union[str, Dict[str, Union[str, List[Dict[str, Union[str, List[Dict[str, Any]]]]]]]], save_to: Optional[str] = None, save_format: Optional[str] = None, current_date: Optional[datetime] = None, raise_exception: bool = True, exception_level: SeverityLevel = SeverityLevel.CRITICAL, template: Optional[dict] = None) Dict[source]
Validate a Deirokay DataFrame against a well-defined Validation Document.
- Parameters
df (pandas.DataFrame) – DataFrame preferencially parsed by Deirokay data_reader.
against (Union[str, dict]) – A dict-like Validation Document or a local/S3 path to a validation file in either YAML or JSON format.
save_to (str, optional) – Path to folder where the validation result document will be saved to. An subfolder named the same as the validation document named will be created in this path, and the results will be saved inside following the <current_date>.<save_format> pattern. <current_date> is formatted as %Y%m%dT%H%M%S and <save_format> can be either yaml or json. If None, no validation log will be saved. By default None.
save_format (str, optional) – Format in which to save the validation document (yaml or json). Only valid when save_to is not None. If None and against is a Python dictionary, defaults to YAML. If None and against is a valid path to a YAML or JSON file, it will keep this format. By default None
current_date (datetime, optional) – Python datetime.datetime to use in log file name when saving validation result. Only valid when save_to is not None. If None, defaults to datetime.utcnow() value and raises a warning. By default None
raise_exception (bool, optional) – Whether or not to raise a ValidationError exception whenever a statement whose level is greater or equal to exception_level fails. By default True
exception_level (SeverityLevel, optional) – Minimum statement severity to raise exception for when statement validation fails. Only valid when raise_exception is True. By default SeverityLevel.CRITICAL (5).
template (dict, optional) – Map of custom templates to be replaced in validation document before evaluation of statements. For mapped values, if callable, the returned value is used instead.
- Returns
Validation Result Document dict.
- Return type
DeirokayValidationResultDocument
- Raises
ValueError – save_to parameter is not a directory neither an S3 path.
ValidationError – Validation failed for at least one statement whose severity is greater or equal to exception_level.