MCPcopy Create free account
hub / github.com/ampproject/amphtml / logValidationResult

Function logValidationResult

validator/cpp/engine/wasm/validator.js:176–211  ·  view source on GitHub ↗

* Log validation result to the console, distinguishing warnings and errors. * @param {!Object} validationResult * @param {string} url

(validationResult, url)

Source from the content-addressed store, hash-verified

174 * @param {string} url
175 */
176function logValidationResult(validationResult, url) {
177 const {
178 status,
179 errors,
180 } = validationResult;
181 if (status === STATUS.nameByNumber.get(ValidationResult.Status.PASS)) {
182 console.info('AMP validation successful.');
183 console.info(
184 `Review our 'publishing checklist' to ensure successful AMP document` +
185 `distribution. See https://go.amp.dev/publishing-checklist`);
186 if (errors.length === 0) {
187 return;
188 }
189 } else if (status !== STATUS.nameByNumber.get(ValidationResult.Status.FAIL)) {
190 console.error(
191 'AMP validation had unknown results. This indicates a validator ' +
192 'bug. Please report at https://github.com/ampproject/amphtml/issues .');
193 }
194 if (status === STATUS.nameByNumber.get(ValidationResult.Status.FAIL)) {
195 console.error('AMP validation had errors:');
196 } else {
197 console.error('AMP validation had warnings:');
198 }
199 for (const error of errors) {
200 if (error.severity ===
201 SEVERITY.nameByNumber.get(ValidationError.Severity.ERROR)) {
202 console.error(errorLine(url, error));
203 } else {
204 console.warn(errorLine(url, error));
205 }
206 }
207 if (errors.length !== 0) {
208 console.info(`See also https://validator.amp.dev/?experimental_wasm=1#url=${
209 encodeURIComponent(uriUtils.removeFragment(url))}`);
210 }
211}
212
213/**
214 * Validates a URL input, and logs the result to console.

Callers 1

validateUrlAndLogFunction · 0.70

Calls 5

errorLineFunction · 0.85
infoMethod · 0.80
warnMethod · 0.80
getMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected