validator/cpp/engine/wasm/validator.js
/**
 * Log validation result to the console, distinguishing warnings and errors.
 * @param {!Object} validationResult
 * @param {string} url
 */
Log validation result to the console, distinguishing warnings and errors.
@param {!Object} validationResult
@param {string} url
Log validation result to the console distinguishing warnings and errors . @param { !Object } validationResult @param { string } url
function logValidationResult(validationResult, url) {
  const {
    status,
    errors,
  } = validationResult;
  if (status === ValidationResult.Status.PASS) {
    console.info('AMP validation successful.');
    console.info(
        `Review our 'publishing checklist' to ensure successful AMP document` +
        `distribution. See https://go.amp.dev/publishing-checklist`);
    if (errors.length === 0) {
      return;
    }
  } else if (status !== ValidationResult.Status.FAIL) {
    console.error(
        'AMP validation had unknown results. This indicates a validator ' +
        'bug. Please report at https://github.com/ampproject/amphtml/issues .');
  }
  if (status === ValidationResult.Status.FAIL) {
    console.error('AMP validation had errors:');
  } else {
    console.error('AMP validation had warnings:');
  }
  for (const error of errors) {
    if (error.severity === ValidationError.Severity.ERROR) {
      console.error(errorLine(url, error));
    } else {
      console.warn(errorLine(url, error));
    }
  }
  if (errors.length !== 0) {
    console.info(`See also https://validator.amp.dev/?experimental_wasm=1#url=${
        encodeURIComponent(uriUtils.removeFragment(url))}`);
  }
}
function logValidationResult ( validationResult , url ) { const { status , errors , } = validationResult ; if ( status === ValidationResult . Status . PASS ) { console . info ( 'AMP validation successful.' ) ; console . info ( ` ` + ` ` ) ; if ( errors . length === 0 ) { return ; } } else if ( status !== ValidationResult . Status . FAIL ) { console . error ( 'AMP validation had unknown results. This indicates a validator ' + 'bug. Please report at https://github.com/ampproject/amphtml/issues .' ) ; } if ( status === ValidationResult . Status . FAIL ) { console . error ( 'AMP validation had errors:' ) ; } else { console . error ( 'AMP validation had warnings:' ) ; } for ( const error of errors ) { if ( error . severity === ValidationError . Severity . ERROR ) { console . error ( errorLine ( url , error ) ) ; } else { console . warn ( errorLine ( url , error ) ) ; } } if ( errors . length !== 0 ) { console . info ( ` ${ encodeURIComponent ( uriUtils . removeFragment ( url ) ) } ` ) ; } }
Log validation result to the console, distinguishing warnings and errors.
Log validation result to the console distinguishing warnings and errors .