52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
"use strict";
|
|
|
|
const React = require("react");
|
|
|
|
const { validateArguments } = require("@validatem/core");
|
|
const required = require("@validatem/required");
|
|
const isString = require("@validatem/is-string");
|
|
const isBoolean = require("@validatem/is-boolean");
|
|
const defaultTo = require("@validatem/default-to");
|
|
const oneOf = require("@validatem/one-of");
|
|
|
|
module.exports = function Module(props_) {
|
|
// TODO: Move this wrapper into a module, `validate-react-props`
|
|
let [ props ] = validateArguments(arguments, [
|
|
[ "props", {
|
|
name: [ required, isString ],
|
|
url: [ isString, defaultTo(`https://www.npmjs.com/package/@validatem/${props_.name}`) ],
|
|
type: [ required, oneOf([ "validator", "combinator", "plumbing" ]) ],
|
|
validates: [ isString ],
|
|
thirdParty: [ isBoolean, defaultTo(false) ]
|
|
}],
|
|
[ "_" ],
|
|
[ "_" ]
|
|
]);
|
|
|
|
// let url = defaultValue(props.url, `https://www.npmjs.com/package/@validatem/${props.name}`);
|
|
|
|
return (
|
|
<a className="entry" href={props.url}>
|
|
<span className="name">{props.name}</span>
|
|
|
|
<span className="meta">
|
|
<span className="label">Type:</span>
|
|
<span className="value">{props.type}</span>
|
|
</span>
|
|
|
|
{(props.validates != null)
|
|
? <span className="meta">
|
|
<span className="label">Validates:</span>
|
|
<span className="value">{props.validates}</span>
|
|
</span>
|
|
: null
|
|
}
|
|
|
|
{(props.thirdParty === true)
|
|
? <span className="thirdParty">Third-party</span>
|
|
: <span className="firstParty">Maintained by core!</span>
|
|
}
|
|
</a>
|
|
);
|
|
};
|