## AsValidator

AsValidator — Validator and report-generator about AppStream XML metadata

## Functions

GQuark | as_validator_error_quark ()
AsValidator * | as_validator_new ()
void | as_validator_clear_issues ()
gboolean | as_validator_validate_file ()
gboolean | as_validator_validate_bytes ()
gboolean | as_validator_validate_data ()
gboolean | as_validator_validate_tree ()
void | as_validator_clear_release_data ()
gboolean | as_validator_add_release_bytes ()
gboolean | as_validator_add_release_file ()
guint | as_validator_get_issue_files_count ()
GList * | as_validator_get_issues ()
GHashTable * | as_validator_get_issues_per_file ()
gboolean | as_validator_get_report_yaml ()
gboolean | as_validator_get_check_urls ()
void | as_validator_set_check_urls ()
gboolean | as_validator_get_strict ()
void | as_validator_set_strict ()
gboolean | as_validator_add_override ()
const gchar * | as_validator_get_tag_explanation ()
AsIssueSeverity | as_validator_get_tag_severity ()
gchar ** | as_validator_get_tags ()

## Types and Values

#define | AS_TYPE_VALIDATOR
struct | AsValidatorClass
enum | AsValidatorError
#define | AS_VALIDATOR_ERROR
| AsValidator

## Includes

    #include <appstream.h>

## Description

This object is able to validate AppStream XML metadata (catalog and metainfo) and to generate a report about issues found with it.

See also: AsMetadata

## Functions

### as_validator_error_quark ()

    GQuark
    as_validator_error_quark (void);

#### Returns

An error quark.

Since: 0.15.4

### as_validator_new ()

    AsValidator *
    as_validator_new (void);

Creates a new AsValidator.

#### Returns

an AsValidator.

[transfer full]

### as_validator_clear_issues ()

    void
    as_validator_clear_issues (AsValidator *validator);

Clears the list of issues

#### Parameters

validator | An instance of AsValidator. |

### as_validator_validate_file ()

    gboolean
    as_validator_validate_file (AsValidator *validator,
                                GFile *metadata_file);

Validate an AppStream XML file. Remember to run `as_validator_clear_issues` if you do not want previous validation runs to affect the outcome of this validation.

#### Parameters

validator | An instance of AsValidator. |
metadata_file | An AppStream XML file. |

#### Returns

`TRUE` if file validated successfully.

### as_validator_validate_bytes ()

    gboolean
    as_validator_validate_bytes (AsValidator *validator,
                                 GBytes *metadata);

Validate AppStream XML data from a byte array. Remember to run `as_validator_clear_issues` if you do not want previous validation runs to affect the outcome of this validation.

#### Parameters

validator | An instance of AsValidator. |
metadata | XML metadata as GBytes. |

#### Returns

`TRUE` if bytes validated successfully.

Since: 0.14.0

### as_validator_validate_data ()

    gboolean
    as_validator_validate_data (AsValidator *validator,
                                const gchar *metadata);

Validate AppStream XML data. Remember to run `as_validator_clear_issues` if you do not want previous validation runs to affect the outcome of this validation.

#### Parameters

validator | An instance of AsValidator. |
metadata | XML metadata. |

#### Returns

`TRUE` if data validated successfully.

### as_validator_validate_tree ()

    gboolean
    as_validator_validate_tree (AsValidator *validator,
                                const gchar *root_dir);

Validate a full directory tree for issues in AppStream metadata.

#### Parameters

validator | An instance of AsValidator. |
root_dir | The root directory of the filesystem tree that should be validated. |

#### Returns

`TRUE` if file validated successfully.

### as_validator_clear_release_data ()

    void
    as_validator_clear_release_data (AsValidator *validator);

Clear all release information that was explicitly added to the validation process.

#### Parameters

validator | a AsValidator instance. |

Since: 0.16.0

### as_validator_add_release_bytes ()

    gboolean
    as_validator_add_release_bytes (AsValidator *validator,
                                    const gchar *release_fname,
                                    GBytes *release_metadata,
                                    GError **error);

Add release metadata explicitly from bytes.

#### Parameters

validator | a AsValidator instance. |
release_fname | File basename of the release metadata file to add. |
release_metadata | Data of the release metadata file. |
error | a GError or `NULL` |

Since: 0.16.0

### as_validator_add_release_file ()

    gboolean
    as_validator_add_release_file (AsValidator *validator,
                                   GFile *release_file,
                                   GError **error);

Add a release metadata file to the validation process.

#### Parameters

validator | a AsValidator instance. |
release_file | Release metadata file to add. |
error | a GError or `NULL` |

Since: 0.16.0

### as_validator_get_issue_files_count ()

    guint
    as_validator_get_issue_files_count (AsValidator *validator);

Get the number of files for which issues have been found.

#### Parameters

validator | An instance of AsValidator. |

#### Returns

The number of files that have issues.

Since: 0.16.0

### as_validator_get_issues ()

    GList *
    as_validator_get_issues (AsValidator *validator);

Get a list of found metadata format issues.

#### Parameters

validator | An instance of AsValidator. |

#### Returns

a list of AsValidatorIssue instances, free with `g_list_free()`.

[element-type AsValidatorIssue][transfer container]

### as_validator_get_issues_per_file ()

    GHashTable *
    as_validator_get_issues_per_file (AsValidator *validator);

Get a hash table of filenames mapped to lists of issues. This is useful if validation was requested for multiple files and a list of issues per-file is desired without prior explicit sorting.

#### Parameters

validator | An instance of AsValidator. |

#### Returns

a file to issue list mapping.

[element-type utf8 GPtrArray(AsValidatorIssue)][transfer none]

Since: 0.12.8

### as_validator_get_report_yaml ()

    gboolean
    as_validator_get_report_yaml (AsValidator *validator,
                                  gchar **yaml_report);

### as_validator_get_check_urls ()

    gboolean
    as_validator_get_check_urls (AsValidator *validator);

#### Parameters

validator | a AsValidator instance. |

#### Returns

`TRUE` in case we check if remote URLs exist.

### as_validator_set_check_urls ()

    void
    as_validator_set_check_urls (AsValidator *validator,
                                 gboolean value);

Set this value to make the AsValidator check whether remote URLs actually exist.

#### Parameters

validator | a AsValidator instance. |
value | `TRUE` if remote URLs should be checked for availability. |

### as_validator_get_strict ()

    gboolean
    as_validator_get_strict (AsValidator *validator);

#### Parameters

validator | a AsValidator instance. |

#### Returns

`TRUE` in case we are in strict mode and consider any issues as fatal.

Since: 0.15.4

### as_validator_set_strict ()

    void
    as_validator_set_strict (AsValidator *validator,
                             gboolean is_strict);

Enable or disable strict mode. In strict mode, any found issue will result in a failed validation (except for issues of "pedantic" severity). Otherwise, only a "warning" or "error" will cause the validation to fail.

#### Parameters

validator | a AsValidator instance. |
is_strict | `TRUE` to enable strict mode. |

Since: 0.15.4

### as_validator_add_override ()

    gboolean
    as_validator_add_override (AsValidator *validator,
                               const gchar *tag,
                               AsIssueSeverity severity_override,
                               GError **error);

Override the severity of a selected tag. For most tags, the severity can not be lowered to a value that makes a validation that would otherwise fail pass (so e.g. an ERROR can not become an INFO). Some tags are explicitly allowed to have their severity lowered to enable validation of e.g. incomplete metadata during development. Increasing the severity of any tag is always allowed.

#### Parameters

validator | a AsValidator instance. |
tag | the issue tag to override, e.g. "release-time-missing" |
severity_override | the new severity for the tag. |
error | a GError or `NULL` |

Since: 0.15.4

### as_validator_get_tag_explanation ()

    const gchar *
    as_validator_get_tag_explanation (AsValidator *validator,
                                      const gchar *tag);

Get the explanatory text for a given issue tag.

#### Parameters

validator | An instance of AsValidator. |

#### Returns

Explanation text.

### as_validator_get_tag_severity ()

    AsIssueSeverity
    as_validator_get_tag_severity (AsValidator *validator,
                                   const gchar *tag);

Get the severity for a given issue tag.

#### Parameters

validator | An instance of AsValidator. |

#### Returns

The AsIssueSeverity

### as_validator_get_tags ()

    gchar **
    as_validator_get_tags (AsValidator *validator);

Get an array of all tags known to the validator.

#### Parameters

validator | An instance of AsValidator. |

#### Returns

A string array of tags.

[transfer full]

## Types and Values

### AS_TYPE_VALIDATOR

    #define AS_TYPE_VALIDATOR (as_validator_get_type ())

### struct AsValidatorClass

    struct AsValidatorClass {
    	GObjectClass		parent_class;
    };

### enum AsValidatorError

The error type.

#### Members

AS_VALIDATOR_ERROR_FAILED | Generic failure |
AS_VALIDATOR_ERROR_OVERRIDE_INVALID | The issue override was not accepted. |
AS_VALIDATOR_ERROR_INVALID_FILENAME | The filename was invalid. |

### AS_VALIDATOR_ERROR

    #define AS_VALIDATOR_ERROR as_validator_error_quark ()

### AsValidator

    typedef struct _AsValidator AsValidator;