metalsmith-validate
A Metalsmith plugin that allows you to validate file metadata. You can check existence, type, and regex pattern. Neat.
Features
- works on files matching pattern
- can specify default for when key unspecified
- can test for existence or for lack thereof
- can validate against type or array of types using type-check
- can match against pattern as RegExp, string, or callback(value) returning boolean
Installation
$ npm install metalsmith-validate
Usage
Validate all files
Pass hash of file metadata keys and rules.
var validate = ; metalsmith;
Validate pattern-matching files
Pass array of hashes with file-matching pattern and metadata validation hash:
var validate = ; metalsmith;
Notice, both default
and pattern
accept callbacks. Also note the file-matching pattern is specified as a path after the metalsmith .source path (e.g. 'post/' and not 'src/post/').
CLI Usage
All of the same options apply, just add them to the "plugins"
key in your metalsmith.json
configuration:
License
MIT