![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
grunt-yaml-validator
Advanced tools
Validate Yaml files and enforce a given structure
Yaml files are parsed via js-yaml
and the structure defined via task configuration is enforced with
check-type
.
This plugin requires Grunt ~0.4
and Node.js 0.10.0
.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-yaml-validator --save-dev
Once the plugin has been installed, it may be enabled inside your
Gruntfile.js
with this line of JavaScript:
grunt.loadNpmTasks('grunt-yaml-validator');
In case you are using an automated loader, such as jit-grunt
,
the above line is not needed.
Please note that this project is a multi task plugin, so pay special attention for configuring it.
Files to be checked with this plugin, should be defined
via src
property.
In your project's Gruntfile, add a section named yaml_validator
to the data object passed
into grunt.initConfig()
.
grunt.initConfig({
yaml_validator: {
options: {
// Task-specific options go here.
},
your_target: {
options: {
// Multi task specific options go here.
}
// Target-specific file lists and/or options go here.
src: []
},
},
});
Type: string|boolean
Default value: 'false'
In case the value is not false
, the given string will be used as log file where all the
task output is written.
Please note that running Grunt with -v
(verbose) mode does make a difference in the
resulting output.
Type: Array
Default value: '[]'
An array to list the property structure which the Yaml files should contain.
Type: Object
Default value: null
Options passed to safeload
method of js-yaml
.
Please note that the onWarning
callback is being used by this plugin and any method written for it,
will be run after the one implemented in this plugin.
The callback get called with two parameters, of which the first is the error in question,
while the second is the file path of the given Yaml file.
By using the default option values, only the validity of the configured Yaml files are checked.
grunt.initConfig({
yaml_validator: {
defaults: {
options: {
log: false,
structure: [],
yaml: null
},
src: ['configuration/*.yml', 'other/important/*_stuff.yml']
}
}
});
All output is written in the log file as well as to the standard output.
grunt.initConfig({
yaml_validator: {
custom: {
options: {
log: 'yaml-validator.log'
},
src: ['configuration/*.yml', 'other/important/*_stuff.yml']
}
}
});
The given structure validation requirements are passed to the has()
method of the
check-type
plugin.
grunt.initConfig({
yaml_validator: {
custom: {
options: {
structure: [
'school',
'school.description',
'school.title',
'school.language'
]
},
src: ['configuration/*.yml', 'other/important/*_stuff.yml']
}
}
});
Using the onWarning
callback, the possible parsing errors can be retrieved.
grunt.initConfig({
yaml_validator: {
custom: {
options: {
yaml: {
onWarning: function (error, filepath) {
console.log(filepath + ' has error: ' + error);
}
}
},
src: ['configuration/*.yml', 'other/important/*_stuff.yml']
}
}
});
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint with ESLint and test your code using unit tests.
Please note that any features or changed will not be merged without working unit tests.
Copyright (c) Juga Paazmaya, under the MIT license
FAQs
Validate Yaml files and enforce a given structure
We found that grunt-yaml-validator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.