How to use tcomb-validation - 10 common examples

To help you get started, we’ve selected a few tcomb-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 ivan-kleshnin / cyclejs-examples / 1.5-form.alt / src / app.js View on Github external
          .map(email => validate(email, User.meta.props.email).firstError())
          .map(error => assoc("email", error && error.message || null)), // TODO simplify?
github ivan-kleshnin / cyclejs-examples / 1.5-form.alt / src / app.js View on Github external
          .map(username => validate(username, User.meta.props.username).firstError())
          .map(error => assoc("username", error && error.message || null)), // TODO simplify?
github cadre / tcomb-builder / src / primitives / __tests__ / TextBuilder.spec.js View on Github external
it('produces a valid type', () => {
    const TextType = TextBuilder.getType();

    expect(validate('banana', TextType).isValid()).to.be.true;
    expect(validate('', TextType).isValid()).to.be.false;
    expect(validate(42, TextType).isValid()).to.be.false;
    expect(validate(null, TextType).isValid()).to.be.false;
    expect(validate(undefined, TextType).isValid()).to.be.false;
    expect(TextType.getValidationErrorMessage('banana')).to.equal(null);
    expect(TextType.getValidationErrorMessage(null)).to.equal('Required');
  });
});
github cadre / tcomb-builder / src / primitives / __tests__ / TextBuilder.spec.js View on Github external
it('produces a valid type', () => {
    const TextType = TextBuilder.getType();

    expect(validate('banana', TextType).isValid()).to.be.true;
    expect(validate('', TextType).isValid()).to.be.false;
    expect(validate(42, TextType).isValid()).to.be.false;
    expect(validate(null, TextType).isValid()).to.be.false;
    expect(validate(undefined, TextType).isValid()).to.be.false;
    expect(TextType.getValidationErrorMessage('banana')).to.equal(null);
    expect(TextType.getValidationErrorMessage(null)).to.equal('Required');
  });
});
github cadre / tcomb-builder / src / primitives / __tests__ / TextBuilder.spec.js View on Github external
it('produces a valid type', () => {
    const TextType = TextBuilder.getType();

    expect(validate('banana', TextType).isValid()).to.be.true;
    expect(validate('', TextType).isValid()).to.be.false;
    expect(validate(42, TextType).isValid()).to.be.false;
    expect(validate(null, TextType).isValid()).to.be.false;
    expect(validate(undefined, TextType).isValid()).to.be.false;
    expect(TextType.getValidationErrorMessage('banana')).to.equal(null);
    expect(TextType.getValidationErrorMessage(null)).to.equal('Required');
  });
});
github cadre / tcomb-builder / src / primitives / __tests__ / NumberBuilder.spec.js View on Github external
it('produces a NumberType that validates correctly', () => {
    const NumberType = NumberBuilder.getType();

    expect(validate('banana', NumberType).isValid()).to.be.false;
    expect(validate(42, NumberType).isValid()).to.be.true;
    expect(NumberType.getValidationErrorMessage('banana')).to.equal('Please provide a number');
    expect(NumberType.getValidationErrorMessage(42)).to.equal(null);
    expect(NumberType.getValidationErrorMessage(null)).to.equal('Please provide a number');
  });
});
github cadre / tcomb-builder / src / primitives / __tests__ / TextBuilder.spec.js View on Github external
it('produces a valid type', () => {
    const TextType = TextBuilder.getType();

    expect(validate('banana', TextType).isValid()).to.be.true;
    expect(validate('', TextType).isValid()).to.be.false;
    expect(validate(42, TextType).isValid()).to.be.false;
    expect(validate(null, TextType).isValid()).to.be.false;
    expect(validate(undefined, TextType).isValid()).to.be.false;
    expect(TextType.getValidationErrorMessage('banana')).to.equal(null);
    expect(TextType.getValidationErrorMessage(null)).to.equal('Required');
  });
});
github Paqmind / react-ultimate / shared / validation.js View on Github external
function validateValue(value, type, key) {
  let result = validate(value, type);
  let valid = result.isValid();
  let errors = valid ? null : unflattenErrors(result.errors, key);
  return {valid, errors};
}
github gcanti / tcomb-form / lib / components / Radio.js View on Github external
getValue: function () {
    var value = this.getTransformer().parse(this.state.value);
    var result = t.validate(value, this.props.ctx.report.type, this.props.ctx.path);
    this.setState({hasError: !result.isValid()});
    return result;
  },
github gcanti / tcomb-form / lib / components / Checkbox.js View on Github external
getValue: function () {
    var value = this.getTransformer().parse(this.state.value);
    var result = t.validate(value, this.props.ctx.report.type, this.props.ctx.path);
    this.setState({hasError: !result.isValid()});
    return result;
  },

tcomb-validation

General purpose validation library for JavaScript

MIT
Latest version published 7 years ago

Package Health Score

55 / 100
Full package analysis

Popular tcomb-validation functions