Skip to content

Commit

Permalink
build: typescript -> type declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Sep 11, 2023
1 parent b03dfdb commit 305a0a5
Show file tree
Hide file tree
Showing 14 changed files with 416 additions and 111 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-walls-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"rdf-validate-datatype": patch
---

Bundle TypeScript declarations in package
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": [ "@tpluscode/eslint-config/js" ],
"extends": [ "@tpluscode" ],
"parserOptions": {
"project": "./tsconfig.json"
},
"env": {
"mocha": true
}
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/node_modules
/dist
/.nyc_output
/coverage
*.d.ts
*.js
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ Validate literal value of an RDF term based on its declared datatype.
### `validateTerm`

```javascript
import validateDatatype from 'rdf-validate-datatype'
import { validateTerm } 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

Expand All @@ -38,12 +36,10 @@ const isValid = validateTerm(term) // -> false
to its declared datatype.

```javascript
import validateDatatype from 'rdf-validate-datatype'
import { validateQuad } 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,
Expand All @@ -64,12 +60,10 @@ const isValid = validateQuad(term) // -> false
Datatype validators are stored in a registry. They can be changed at runtime.

```javascript
import validateDatatype from 'rdf-validate-datatype'
import { validators, validateTerm } 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-'))
Expand Down
File renamed without changes.
Loading

0 comments on commit 305a0a5

Please sign in to comment.