How to use @learninglocker/xapi-validation - 10 common examples

To help you get started, we’ve selected a few @learninglocker/xapi-validation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LearningLocker / learninglocker / ui / src / pages / PeopleManagePage / IfiEditor / IfiOpenIdEditor.js View on Github external
const render = ({ value, onChange, onSave, refValueInput }) => {
  const hasOpenIdError = validateIri(value, ['openid']).length !== 0;
  return (
    <div>
      <input placeholder="OpenID URL" value="{value}">
      
        Must be a valid URL.
      
    </div>
  );
};
github LearningLocker / learninglocker / ui / src / pages / PeopleManagePage / IdentifiersEditor / hasIdentifierValueErrors.js View on Github external
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;
    }
  }
github LearningLocker / learninglocker / lib / services / persona / validateIfi.js View on Github external
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'];
};
github LearningLocker / learninglocker / ui / src / pages / PeopleManagePage / IfiEditor / IfiAccountEditor.js View on Github external
const render = ({ value, onChange, onSave, refHomePageInput, refNameInput }) =&gt; {
  const homePage = value.get('homePage');
  const name = value.get('name');
  const hasHomePageError = validateIri(homePage, ['homepage']).length !== 0;
  const hasNameError = name.length === 0;
  const handleHomePageChange = (newHomePage) =&gt; {
    onChange(value.set('homePage', newHomePage));
  };
  const handleNameChange = (newName) =&gt; {
    onChange(value.set('name', newName));
  };
  return (
    <div>
      <div>
        <input placeholder="Website" value="{homePage}"></div></div>
github LearningLocker / learninglocker / ui / src / pages / PeopleManagePage / IdentifiersEditor / hasIdentifierValueErrors.js View on Github external
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;
    }
  }
};
github LearningLocker / learninglocker / ui / src / pages / PeopleManagePage / IfiEditor / IfiMboxEditor.js View on Github external
const render = ({ value, onChange, onSave, refValueInput }) =&gt; {
  const hasMboxError = validateMailto(value, ['mbox']).length !== 0;
  const handleChange = (newValue) =&gt; {
    onChange(`mailto:${newValue}`);
  };
  return (
    <div>
      <input placeholder="Email address" value="{value.replace('mailto:',">
      
        <span>Must be a valid email address.</span>
      
    </div>
  );
github LearningLocker / learninglocker / ui / src / pages / PeopleManagePage / IdentifiersEditor / hasIdentifierValueErrors.js View on Github external
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;
    }
  }
};
github LearningLocker / learninglocker / lib / services / persona / validateIfi.js View on Github external
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'];
};
github LearningLocker / learninglocker / ui / src / pages / PeopleManagePage / IfiEditor / IfiMboxShaEditor.js View on Github external
const render = ({ value, onChange, onSave, refValueInput }) =&gt; {
  const hasSha1Error = validateSha1(value, ['mbox_sha1sum']).length !== 0;
  return (
    <div>
      <input placeholder="Sha1 encrypted email address" value="{value}">
      
        Must be valid Sha1 text.
      
    </div>
  );
};
github LearningLocker / learninglocker / lib / services / persona / validateIfi.js View on Github external
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'];
};

@learninglocker/xapi-validation

Validation library for the xAPI.

MIT
Latest version published 1 year ago

Package Health Score

52 / 100
Full package analysis

Similar packages