Skip to content

Commit

Permalink
Display "Header is valid" when no issue was detected (#526)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Paseltiner <apaseltiner@google.com>
  • Loading branch information
maudnals and apasel422 committed Jul 27, 2022
1 parent 9bbe9bd commit d31c623
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions validate-headers.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ <h1>Attribution Reporting Header Validation</h1>
<legend>Validation Result</legend>
<button type=button id=linkify>Copy Link</button>
<output>
<div id=success></div>
<p>Errors:
<ul id=errors></ul>
<p>Warnings:
Expand All @@ -85,6 +86,7 @@ <h1>Attribution Reporting Header Validation</h1>
const input = form.querySelector('textarea');
const errorList = document.querySelector('#errors');
const warningList = document.querySelector('#warnings');
const successDiv = document.querySelector('#success');

const pathfulTmpl = document.querySelector('#pathful-issue');

Expand Down Expand Up @@ -120,6 +122,14 @@ <h1>Attribution Reporting Header Validation</h1>

const result = validateJSON(input.value, validate);

const successEl = document.createElement('div');
if (result?.errors?.length === 0 && result?.warnings?.length === 0) {
successEl.textContent = 'The header is valid.';
} else {
successEl.textContent = '';
}
successDiv.replaceChildren(successEl);

errorList.replaceChildren(...result.errors.map(makeLi));
warningList.replaceChildren(...result.warnings.map(makeLi));
});
Expand Down

0 comments on commit d31c623

Please sign in to comment.