{"id":15396159,"url":"https://github.com/jamesseanwright/valimate","last_synced_at":"2025-04-16T00:16:55.931Z","repository":{"id":43974207,"uuid":"49221896","full_name":"jamesseanwright/valimate","owner":"jamesseanwright","description":"Automated HTML validation via Node.js","archived":false,"fork":false,"pushed_at":"2022-12-30T19:54:21.000Z","size":319,"stargazers_count":30,"open_issues_count":6,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T03:11:18.739Z","etag":null,"topics":["html","html-validation","nu-html-checker","w3c-validator"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jamesseanwright.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-07T18:16:54.000Z","updated_at":"2024-12-15T18:26:52.000Z","dependencies_parsed_at":"2023-01-31T15:15:18.883Z","dependency_job_id":null,"html_url":"https://github.com/jamesseanwright/valimate","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesseanwright%2Fvalimate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesseanwright%2Fvalimate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesseanwright%2Fvalimate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesseanwright%2Fvalimate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamesseanwright","download_url":"https://codeload.github.com/jamesseanwright/valimate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631680,"owners_count":21136562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html","html-validation","nu-html-checker","w3c-validator"],"created_at":"2024-10-01T15:31:47.185Z","updated_at":"2025-04-16T00:16:55.896Z","avatar_url":"https://github.com/jamesseanwright.png","language":"JavaScript","readme":"# Valimate\n\n[![Build status](https://api.travis-ci.org/jamesseanwright/valimate.svg)](https://travis-ci.org/jamesseanwright/valimate) [![Coverage Status](https://coveralls.io/repos/github/jamesseanwright/valimate/badge.svg?branch=master)](https://coveralls.io/github/jamesseanwright/valimate?branch=master) [![npm version](https://badge.fury.io/js/valimate.svg)](https://www.npmjs.com/package/valimate)\n\nValimate is a configurable command line interface for validating local and remote websites against the [Nu HTML Checker](https://github.com/validator/validator). It can be easily integrated with continuous integration pipelines and regression test suites.\n\nRequires **Node.js 10 or greater**\n\n\n## Installing\n\n```\nnpm i --save-dev valimate\n```\n\n\n## Configuration\n\nValimate is configured on a per-project basis via the [valimate.json](https://github.com/jamesseanwright/valimate/wiki/valimate.json) file. This must reside in the root directory of your project. A simple configuration might look like this:\n\n```javascript\n{\n  \"urls\": [\n    \"http://jamesswright.co.uk/\",\n    \"http://jamesswright.co.uk/about-me\",\n    \"http://jamesswright.co.uk/skills\"\n  ]\n}\n```\n\nTo validate these URLs, run `npx valimate` in your terminal or `valimate` within the context of an npm script. Valimate will read the config; each URL is requested via HTTP GET, and the returned markup is sent to the Nu validator.\n\nAll of the configuration options are listed on the [valimate.json wiki page](https://github.com/jamesseanwright/valimate/wiki/valimate.json).\n\n## Running with another configuration file\n\nRun `npx valimate file.json` in your terminal or `valimate file.json` within the context of an npm script.\n\n## Running against a local app server\n\nIn a continuous integration scenario, it could be ideal validate your app server with the latest code changes. If this server is developed in Node.js, then you can use the [Valimate Notifier](https://github.com/jamesseanwright/valimate-notifier) module to defer the execution of tests until the server has started up and is ready to serve HTML.\n\nIn the valimate.json file, set the `localAppServer` to point to your server's entry script. You can also use the `env` property to pass environment variables to the process as key-value pairs:\n\n```javascript\n{\n  \"localAppServer\": {\n    \"entryPoint\": \"app.js\",\n\n    \"env\": {\n      \"TEST\": \"true\"\n    }\n  },\n\n  \"urls\": [\n    \"http://localhost:8081/\"\n  ]\n}\n```\n\nThen use the Valimate Notifier module to notify Valimate when the server is ready to be validated. The module exports a fuction which accepts one argument; a truthy value suggests that start up was successful, whereas a falsy value suggests failure, causing Valimate to exit:\n\n```javascript\n'use strict';\n\nconst http = require('http');\nconst notifyValimate = require('valimate-notifier');\nconst dataService = require('./services/myDataService');\nconst htmlBuilder = require('./view/htmlBuilder');\n\nconst PORT = 8081;\n\ndataService.someAsyncOperation().then(data =\u003e {\n  http.createServer((req, res) =\u003e {\n    res.end(htmlBuilder(data), 'utf-8');\n  }).listen(PORT, () =\u003e {\n    notifyValimate(true);\n  });\n}).catch(e =\u003e notifyValimate(false));\n```\n\nUpon running the `valimate` CLI, your app server will be started as a child process, and killed when testing is complete.\n\nIf your app server has not been started by Valimate (e.g. running in production), then this method will do nothing.\n\n\n## Programmatic Use\n\nValimate can also be imported into your Node.js scripts as a CommonJS module. It exposes the `validate` method, which takes the config as a parameter of the `Object` type. This returns a `Promise` which resolves once the URLs have been validated. A `Boolean` is passed through the chain that will be `true` if the markup is invalid, or `false` if it is valid.\n\n```javascript\n'use strict';\n\nconst valimate = require('valimate');\n\nconst config = {\n  urls: [\n    'http://jamesswright.co.uk/',\n    'http://jamesswright.co.uk/about-me',\n    'http://jamesswright.co.uk/skills'\n  ]\n};\n\n/* protip: ~ = bitwise NOT - can use this twice to doubly\n * invert the bits to coerce a bool to 1 or 0 */\nvalimate.validate(config)\n  .then(isInvalid =\u003e process.exit(~~isInvalid));\n```\n\nUsing Valimate programmatically will still print results as if the library had been invoked via the CLI; this capability is simply a means of convenience; this can be useful when there are many asynchronous prerequisites involved. In the next major release, however, this _may_ directly expose validation results.\n\n\n## Contributing\n\nSee the [Contributing wiki page](https://github.com/jamesseanwright/valimate/wiki/contributing).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesseanwright%2Fvalimate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamesseanwright%2Fvalimate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesseanwright%2Fvalimate/lists"}