Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @rdfdev/prop-types

js.rdf.dev/prop-types

Read the Docs npm (tag) npm bundle size

React prop-type declarations for the RDF data structures.

Example

import PropTypes from "prop-types";
import RDFTypes from "@rdfdev/prop-types";

const MyComponent = () => {}; // Omitted for brevity

MyComponent.propTypes = {
  // The name as an RDF Literal (e.g. xsd:string)
  name: RDFTypes.literal,
  // The IRI of the author
  author: RDFTypes.namedNode,
  // The statements/quads on their books.
  bookData: PropTypes.arrayOf(RDFTypes.quad),
  // A link to the comments, either an IRI (e.g. https) or blank (temporary document-scoped link)
  comments: RDFTypes.nodeType,
};

Getting started

Just install the package and its peer dependencies.

npm i @rdfdev/prop-types @ontologies/core prop-types

yarn add @rdfdev/prop-types @ontologies/core prop-types

Documentation

See the js.rdf.dev/prop-types documentation

See the complete js.rdf.dev documentation

Need help with linked data?

This package is brought to you by Ontola. We build production-grade linked data solutions and can help you from advice to building custom web services.

Index

Variables

Const blankNode

blankNode: any = shape({termType: oneOf([TermType.BlankNode]).isRequired,value: string.isRequired,})

Validate if the prop is a valid BlankNode.

Const literal

literal: any = shape({termType: oneOf([TermType.Literal]).isRequired,value: string.isRequired,datatype: namedNode,language: string.isRequired,})

Validate if the prop is a valid Literal.

Const namedNode

namedNode: any = shape({termType: oneOf([TermType.NamedNode]).isRequired,value: string.isRequired,})

Validate if the prop is a valid NamedNode.

Const nodeType

nodeType: any = oneOfType([blankNode, namedNode])

Validate if the prop is a valid node (blank or named).

Const quad

quad: any = shape({subject: oneOfType([ blankNode, namedNode ]).isRequired,predicate: namedNode.isRequired,object: oneOfType([ blankNode, namedNode, literal ]).isRequired,graph: oneOfType([ blankNode, namedNode ]),})

Validate if the prop is a valid Quad.

Const termType

termType: any = oneOfType([blankNode, namedNode, literal])

Validate if the prop is a valid term (blank node, named node, or literal).

Generated using TypeDoc