Package Exports
- schema-validator
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (schema-validator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Validator JS
Barebones schema validation library for things such as database schemas, api data schemas, etc.
Extensions
- Requirement (built-in)
- Type - uses
Object.prototype.toString.callso make sure you useString,Number,Boolean... etc. - Length - By itself it must be this long, otherwise as an object supports the following:
- Min
- Max
- Test (Regular expression tests)
- Supports an array of RegExps as well.
Creating an extension
Implementing a feature into Validator is easy, you set the field and a callback, the callback gives you three items of data details (the whole schema, and your field is included so you can do cross checks if needed), key (the name of the parameter), data (retrieved parameter data from external source, you check against this).
Validator.implement("field", function (details, key, data) {
this.error(key, "error-field", "No check has been done against this key!");
});After your implementation has been ran, the validator will check for errors, if found it will exit out and return the errors. You can pass along multiple errors per run, for an example check the test implementation.
Todo
Make extensibility easier.- Make implementations use an object as an argument rather than multiple arguments to allow for further expansion.
- Move over to github repository.
Changelog
Version 3.1
- Extended comments
- Implemented module exporting for various platforms.
Version 3
- Remove console logging
- Implement plugin system -
.implementmethod
Version 2
- Fix slight bugs in matching validation check
- Make errors Object based for quick key referencing
Version 1
- Initial Release.