npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@bernierllc/validators-content

v1.0.2

Published

Content quality validation - composite validator combining link integrity, image optimization, editorial style, and markdown structure validation

Readme

@bernierllc/validators-content

Content quality validation - composite validator combining link integrity, image optimization, editorial style, and markdown structure validation.

Overview

The validators-content package is a domain validator that orchestrates multiple primitive validators to provide comprehensive content quality assurance. It validates links, images, editorial style, and markdown structure in a single operation.

Installation

npm install @bernierllc/validators-content

Features

  • Link Integrity: Validates broken links, anchor targets, redirect chains, and protocol consistency
  • Image Assets: Checks alt text, image format, file size, dimensions, and srcset
  • Editorial Style: Validates inclusive language, brand terms, tone, and readability
  • Markdown Structure: Verifies heading hierarchy, link references, list formatting, and code blocks
  • Flexible Configuration: Enable/disable individual validators as needed
  • Multiple Content Types: Supports markdown, HTML, and plain text

Usage

Basic Example

import { validateContent } from '@bernierllc/validators-content';
import { createSharedUtils } from '@bernierllc/validators-utils';

const utils = createSharedUtils();

const content = {
  markdown: `
# Welcome

Check out [our site](https://example.com)!

![Logo](logo.png "Company Logo")
  `.trim(),
};

const result = await validateContent(content, {}, utils);

if (result.problems.length === 0) {
  console.log('Content is valid!');
} else {
  result.problems.forEach(problem => {
    console.log(`${problem.severity}: ${problem.message}`);
  });
}

With Custom Options

import { validateContent } from '@bernierllc/validators-content';
import { createSharedUtils } from '@bernierllc/validators-utils';

const utils = createSharedUtils();

const content = {
  html: '<h1>Title</h1><p>Some content with <a href="/docs">link</a></p>',
  baseUrl: 'https://mysite.com',
};

const result = await validateContent(content, {
  validateLinks: true,
  validateImages: true,
  validateEditorialStyle: false, // Skip editorial validation
  validateMarkdownStructure: false, // Skip markdown validation
  maxContentLength: 10000, // Warn if content exceeds 10KB
  skipExternalLinks: true, // Don't check external links
}, utils);

Using the Validator Factory

import { createContentValidator } from '@bernierllc/validators-content';
import { createSharedUtils } from '@bernierllc/validators-utils';

const utils = createSharedUtils();

// Create a configured validator
const validator = createContentValidator({
  validateLinks: true,
  validateImages: true,
  validateEditorialStyle: true,
  validateMarkdownStructure: true,
});

// Get metadata
const meta = validator.getMeta();
console.log('Validator:', meta.name);
console.log('Enabled rules:', meta.enabledRules);

// Validate content
const content = {
  text: 'Check out this link: https://example.com',
};

const result = await validator.validate(content, utils);
console.log('Problems found:', result.problems.length);

API

validateContent(content, options?, utils)

Validates content using configured validators.

Parameters:

  • content (ContentInput): Content to validate
    • text?: string - Plain text content
    • html?: string - HTML content
    • markdown?: string - Markdown content
    • baseUrl?: string - Base URL for resolving relative links
    • filePath?: string - Source file path (for context)
  • options? (ContentValidationOptions): Validation options
    • validateLinks?: boolean - Validate link integrity (default: true)
    • validateImages?: boolean - Validate image assets (default: true)
    • validateEditorialStyle?: boolean - Validate editorial style (default: true)
    • validateMarkdownStructure?: boolean - Validate markdown structure (default: true)
    • severity?: Severity - Severity level for problems (default: 'warn')
    • linkOptions?: Partial<LinkIntegrityOptions> - Options for link validation
    • skipExternalLinks?: boolean - Skip external link checking (default: false)
    • maxContentLength?: number - Maximum content length (default: unlimited)
  • utils (SharedUtils): Shared utilities from @bernierllc/validators-utils

Returns: Promise<ValidationResult>

createContentValidator(options?)

Creates a configured content validator instance.

Parameters:

  • options? (ContentValidationOptions): Validation configuration

Returns: Object with:

  • validate(content, utils) - Validation function
  • getMeta() - Metadata function

Content Types

The validator supports three content types:

Markdown Content

const content = {
  markdown: '# Title\n\n[Link](https://example.com)\n\n![Image](image.png)',
};

For markdown content:

  • Links are extracted from [text](url) syntax
  • Images are extracted from ![alt](src) syntax
  • Markdown structure is validated if enabled

HTML Content

const content = {
  html: '<h1>Title</h1><p><a href="https://example.com">Link</a></p>',
};

For HTML content:

  • Links are extracted from <a href="..."> tags
  • Images are extracted from <img src="..."> tags
  • HTML structure is validated through editorial rules

Plain Text Content

const content = {
  text: 'Plain text content with no markup.',
};

For plain text content:

  • Editorial style validation is performed
  • Links and images are not extracted

Composed Validators

This domain validator composes four primitive validators:

1. Link Integrity (@bernierllc/validators-link-integrity)

Validates:

  • Broken links
  • Anchor targets
  • Redirect chains
  • Protocol consistency

2. Image Asset (@bernierllc/validators-image-asset)

Validates:

  • Missing alt text
  • Inefficient image format
  • Excessive file size
  • Excessive dimensions
  • Missing srcset

3. Editorial Style (@bernierllc/validators-editorial-style)

Validates:

  • Inclusive language
  • Brand terms
  • Prohibited terms
  • Tone validation
  • Readability score

4. Markdown Structure (@bernierllc/validators-markdown-structure)

Validates:

  • Heading hierarchy
  • Link references
  • List formatting
  • Code block syntax

Configuration Examples

Strict Link Checking

const result = await validateContent(content, {
  validateLinks: true,
  linkOptions: {
    checkBrokenLinks: true,
    checkAnchorTargets: true,
    checkRedirectChains: true,
    checkProtocolConsistency: true,
  },
}, utils);

Content Length Limits

const result = await validateContent(content, {
  maxContentLength: 5000, // Warn if content exceeds 5KB
  severity: 'error', // Treat warnings as errors
}, utils);

Selective Validation

// Only validate links and images
const result = await validateContent(content, {
  validateLinks: true,
  validateImages: true,
  validateEditorialStyle: false,
  validateMarkdownStructure: false,
}, utils);

Integration Status

  • Logger Integration: Not applicable - Pure validation function with no runtime logging requirements
  • Docs-Suite: Ready - Exports markdown documentation
  • NeverHub Integration: Not applicable - Stateless validator with no service discovery or event bus requirements

Dependencies

BernierLLC Packages:

  • @bernierllc/validators-core - Core validation framework
  • @bernierllc/validators-runner - Validation runner
  • @bernierllc/validators-utils - Shared utilities
  • @bernierllc/validators-link-integrity - Link integrity validation
  • @bernierllc/validators-image-asset - Image asset validation
  • @bernierllc/validators-editorial-style - Editorial style validation
  • @bernierllc/validators-markdown-structure - Markdown structure validation

Related Packages

  • @bernierllc/validators-email - Email content validation
  • @bernierllc/validators-web - Web page validation
  • @bernierllc/validators-api - API specification validation

License

Copyright (c) 2025 Bernier LLC. All rights reserved.