Improved double check

This commit is contained in:
Miel Vander Sande 2014-04-21 14:18:02 +02:00
parent 8e3a95a0c3
commit 9eef604748
2 changed files with 29 additions and 15 deletions

View File

@ -29,13 +29,13 @@ parser.parse(turtleStream, function (error, triple, prefixes){
switch(type) { switch(type) {
case 'float': case 'float':
case 'double': case 'double':
if (!value.match(/[-+]?\d*[.]\d+/)){ if (!(/[-+]?\d*[.]\d+/.test(value))){
console.log('WARNING: datatype does not validate for value ' + value); console.log('WARNING: datatype does not validate for value ' + value);
console.log(triple.subject, triple.predicate, triple.object, '.'); console.log(triple.subject, triple.predicate, triple.object, '.');
} }
break; break;
case 'int': case 'int':
if (!value.match(/[-+]?\d*/)){ if (!(/^\+?(0|[1-9]\d*)$/.test(value))){
console.log('WARNING: int does not validate for value ' + value); console.log('WARNING: int does not validate for value ' + value);
console.log(triple.subject, triple.predicate, triple.object, '.'); console.log(triple.subject, triple.predicate, triple.object, '.');
} }

View File

@ -1,15 +1,29 @@
{ {
"name": TurtleValidator", "name": "turtle-validator",
"version": "0.1.0", "version": "0.1.0",
"license": "", "description": "This command line tool validates Turtle documents and does XSD datatype checks",
"bin": { "main": "TurtleValidator.js",
"genmem": "./bin/TurtleValidator"
},
"dependencies": { "dependencies": {
"n3": "*" "n3": "~0.2.6"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/mmlab/N3Validator.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"
} }