const render = ({ value, onChange, onSave, refValueInput }) => {
  const hasSha1Error = validateSha1(value, ['mbox_sha1sum']).length !== 0;
  return (
    <div className={classNames({ 'has-error': hasSha1Error })}>
      <Input
        value={value}
        placeholder="Sha1 encrypted email address"
        onChange={onChange}
        onSubmit={onSave}
        inputRef={refValueInput} />
      <ErrorText hasError={value.length !== 0 && hasSha1Error}>
        Must be valid Sha1 text.
      </ErrorText>
    </div>
  );
};
Пример #2
0
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'];
};