Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const render = ({ value, onChange, onSave, refValueInput }) => {
const hasMboxError = validateMailto(value, ['mbox']).length !== 0;
const handleChange = (newValue) => {
onChange(`mailto:${newValue}`);
};
return (
<div>
<input placeholder="Email address" value="{value.replace('mailto:',">
<span>Must be a valid email address.</span>
</div>
);
export default (identifierType, identifierValue) => {
switch (identifierType) {
case 'account': {
const homePage = identifierValue.get('homePage');
const name = identifierValue.get('name');
const hasHomePageErrors = validateIri(homePage, ['homePage']).length !== 0;
const hasNameErrors = name.length === 0;
return hasHomePageErrors || hasNameErrors;
}
case 'mbox': {
return validateMailto(identifierValue, ['mbox']).length !== 0;
}
case 'mbox_sha1sum': {
return identifierValue.length === 0;
}
case 'openid': {
return validateIri(identifierValue, ['openid']).length !== 0;
}
default: {
return true;
}
}
};
export const validateIfi = (ifi, path) => {
const valuePath = [...path, 'value'];
if (ifi.key === 'mbox') {
return validateMailto(ifi.value, valuePath);
}
if (ifi.key === 'mbox_sha1sum') {
return validateSha1(ifi.value, valuePath);
}
if (ifi.key === 'openid') {
return validateIri(ifi.value, valuePath);
}
if (ifi.key === 'account') {
return restrictToSchema({
homePage: required(validateIri),
name: required(checkType(String))
})(ifi.value, valuePath);
}
return ['invalid key'];
};