Skip to content

Commit

Permalink
Add support for boolean literals
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminaaron committed May 7, 2024
1 parent 1d18c4c commit 204a2f1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dev/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async function devConvertUserProfileToTurtle() {

async function devValidateSingleDatafieldValue() {
let datafieldsStr = await fsPromise.readFile(DATAFIELDS, "utf8")
let singleDatafieldValue = { "ff:paysRentCold": 900 }
let singleDatafieldValue = { "ff:eligibleForSocialSupport": true }
let result = await validateSingleDatafieldValue(singleDatafieldValue, datafieldsStr)
console.log(result)
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@foerderfunke/matching-engine",
"version": "0.4.3",
"version": "0.4.4",
"description": "Checks eligibilities by validating a user profile against requirement profiles",
"author": "@foerderfunke",
"license": "MIT",
Expand Down
3 changes: 3 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ export async function convertUserProfileToTurtle(userProfileJson) {
}

function determineObjectType(objectStr) {
if (typeof objectStr === "boolean") return literal(objectStr)
objectStr = objectStr.toString()
if (objectStr.toLowerCase() === "true") return literal(true)
if (objectStr.toLowerCase() === "false") return literal(false)
if (objectStr.startsWith("http")) return namedNode(objectStr)
if (objectStr.startsWith("ff:")) return namedNode("https://foerderfunke.org/default#" + objectStr.slice(3))
if (/^\d{4}-\d{2}-\d{2}$/.test(objectStr)) return literal(objectStr, { value: "xsd:date" })
Expand Down

0 comments on commit 204a2f1

Please sign in to comment.