Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
rdf-validate-datatype
Advanced tools
Validate literal value of an RDF term based on its declared datatype.
$ npm install rdf-validate-datatype
validateTerm
import validateDatatype from 'rdf-validate-datatype'
import rdf from '@rdfjs/data-model'
import { xsd } from '@tpluscode/rdf-ns-builders'
const { validateTerm } = validateDatatype
const term = rdf.literal('test')
const isValid = validateTerm(term) // -> true
const term = rdf.literal('2019-01-01', xsd.date)
const isValid = validateTerm(term) // -> true
const term = rdf.literal('invalid date', xsd.date)
const isValid = validateTerm(term) // -> false
validateQuad
validateQuad
validates that the .object
of a given quad is valid in regards
to its declared datatype.
import validateDatatype from 'rdf-validate-datatype'
import rdf from '@rdfjs/data-model'
import { schema, xsd } from '@tpluscode/rdf-ns-builders'
const { validateQuad } = validateDatatype
const quad = rdf.quad(
rdf.namedNode('bob'),
schema.birthDate,
rdf.literal('2019-01-01', xsd.date)
)
const isValid = validateQuad(term) // -> true
const quad = rdf.quad(
rdf.namedNode('bob'),
schema.birthDate,
rdf.literal('invalid date', xsd.date)
)
const isValid = validateQuad(term) // -> false
Datatype validators are stored in a registry. They can be changed at runtime.
import validateDatatype from 'rdf-validate-datatype'
import rdf from '@rdfjs/data-model'
import { xsd } from '@tpluscode/rdf-ns-builders'
const { validators, validateTerm } = validateDatatype
// Register a new datatype
const myDatatype = rdf.namedNode('my-datatype')
validators.register(myDatatype, value => value.startsWith('X-'))
validateTerm(rdf.literal('X-test', myDatatype)) // -> true
validateTerm(rdf.literal('test', myDatatype)) // -> false
// Override an existing datatype
validators.register(xsd.date, value => true)
validateTerm(rdf.literal('banana', xsd.date)) // -> true
0.1.4 (2021-08-02)
xsd:gMonth
FAQs
Validate literal value of an RDF term based on its datatype.
The npm package rdf-validate-datatype receives a total of 8,089 weekly downloads. As such, rdf-validate-datatype popularity was classified as popular.
We found that rdf-validate-datatype demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.