reduced to web version
This commit is contained in:
parent
b1df716e69
commit
e7d5e5eda1
|
@ -1,40 +0,0 @@
|
|||
var N3 = require('n3');
|
||||
|
||||
var validate = function (turtleStream, callback) {
|
||||
var parser = N3.Parser({ format: 'text/turtle' });
|
||||
var errorCount = 0, warningCount = 0;
|
||||
var regexp = {
|
||||
'dateTime' : /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])?T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)??(Z|[+-](?:2[0-3]|[0-1][0-9]):[0-5][0-9])?$/,
|
||||
'double' : /[-+]?\d*([.]\d+)?/,
|
||||
'float' : /[-+]?\d*[.]\d+/,
|
||||
'int' : /^[-+]?(0|[1-9]\d*)$/
|
||||
};
|
||||
|
||||
var feedback = { warnings : [], errors : []};
|
||||
|
||||
parser.parse(turtleStream, function(error, triple, prefixes) {
|
||||
if (error) {
|
||||
feedback.errors.push(error.message);
|
||||
}
|
||||
|
||||
if (triple) {
|
||||
if (triple.object.termType === 'literal') {
|
||||
var value = triple.object.value;
|
||||
var type = triple.object.datatype;
|
||||
|
||||
type = type.replace('http://www.w3.org/2001/XMLSchema#', '');
|
||||
if (regexp[type] && !regexp[type].test(value)) {
|
||||
feedback.warnings.push('xsd:', type, 'does not validate for literal. {', triple.subject.value, triple.predicate.value, triple.object.value, '}');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
callback(feedback);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.validate = validate;
|
||||
}
|
||||
|
||||
module.exports = validate;
|
File diff suppressed because it is too large
Load Diff
40
package.json
40
package.json
|
@ -1,40 +0,0 @@
|
|||
{
|
||||
"name": "turtle-validator",
|
||||
"version": "1.1.0",
|
||||
"description": "This command line tool validates Turtle documents and does XSD datatype checks",
|
||||
"main": "lib/validator.js",
|
||||
"bin": {
|
||||
"ttl": "./TurtleValidator.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"n3": "1.0.0-beta.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.2.3",
|
||||
"local-web-server": "^2.6.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "browserify lib/validator.js -o public/js/ttl.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "npm install && npm build && ws"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/mmlab/TurtleValidator.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Turtle",
|
||||
"RDF",
|
||||
"Semantic",
|
||||
"Web"
|
||||
],
|
||||
"author": "Miel Vander Sande",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mmlab/TurtleValidator/issues"
|
||||
},
|
||||
"homepage": "https://github.com/mmlab/TurtleValidator"
|
||||
}
|
Loading…
Reference in New Issue