How to use availity-reactstrap-validation - 10 common examples

To help you get started, we’ve selected a few availity-reactstrap-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 Availity / availity-reactstrap-validation / __test__ / AvValidator.maxchecked.spec.js View on Github external
import {AvValidator} from 'availity-reactstrap-validation';

const fn = AvValidator.maxChecked;

describe('Max Checked Validation', () => {
  it('should not require a value', () => {
    expect(fn('')).to.be.true;
  });

  it('have an alias of maxChecked', () => {
    expect(fn).to.equal(AvValidator.maxChecked);
  });

  it('should return false if the value is greater than the constraint', () => {
    expect(fn(undefined, undefined, {value: 1}, {value: ['a', 'b']})).to.be.false;
  });

  it('should return true if the value is the same as the constraint', () => {
    expect(fn(undefined, undefined, {value: 2}, {value: ['a', 'b']})).to.be.true;
github Availity / availity-reactstrap-validation / __test__ / AvValidator.maxchecked.spec.js View on Github external
it('have an alias of maxChecked', () => {
    expect(fn).to.equal(AvValidator.maxChecked);
  });
github Availity / availity-reactstrap-validation / __test__ / AvValidator.minchecked.spec.js View on Github external
it('have an alias of minChecked', () => {
    expect(fn).to.equal(AvValidator.minChecked);
  });
github Availity / availity-reactstrap-validation / __test__ / AvValidator.minchecked.spec.js View on Github external
import {AvValidator} from 'availity-reactstrap-validation';

const fn = AvValidator.minChecked;

describe('Min Checked Validation', () => {
  it('should not require a value', () => {
    expect(fn('')).to.be.true;
  });

  it('have an alias of minChecked', () => {
    expect(fn).to.equal(AvValidator.minChecked);
  });

  it('should return true if the value is greater than the constraint', () => {
    expect(fn(undefined, undefined, {value: 1}, {value: ['a', 'b']})).to.be.true;
  });

  it('should return true if the value is the same as than the constraint', () => {
    expect(fn(undefined, undefined, {value: 1}, {value: ['a']})).to.be.true;
github Availity / availity-reactstrap-validation / __test__ / AvValidator.date.spec.js View on Github external
import {AvValidator} from 'availity-reactstrap-validation';
import {inputTypeOverride} from 'availity-reactstrap-validation/AvValidator/utils';

const fn = AvValidator.date;
const input = {props: {type: 'text'}};
const context = {};

describe('Date Validation', () => {
  it('should not require a value', () => {
    expect(fn('', context, undefined, input)).to.be.true;
  });

  describe('error message', () => {
    it('should allow the error message to be overridden', () => {
      expect(fn('abc 123', context, {errorMessage: 'Custom'}, input)).to.equal('Custom');
    });

    it('should use the custom format in the default message', () => {
      expect(fn('abc 123', context, {format: 'YYYY-MM-DD'}, input)).to.equal('Format needs to be YYYY-MM-DD');
    });
github Availity / availity-reactstrap-validation / __test__ / AvValidator.dateRange.spec.js View on Github external
import dayjs from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat'
import {AvValidator} from 'availity-reactstrap-validation';
import {inputTypeOverride} from 'availity-reactstrap-validation/AvValidator/utils';

dayjs.extend(customParseFormat);

const fn = AvValidator.dateRange;
const input = {props: {type: 'text'}};
const context = {};
let date0;
let date1;
let date2;

describe('Date Range Validation', () => {
  beforeEach(() => {
    date0 = dayjs(new Date());
    date1 = dayjs(new Date());
    date2 = dayjs(new Date());
  });

  it('should not require a value', () => {
    expect(fn('', context, undefined, input)).to.be.true;
  });
github Availity / availity-reactstrap-validation / __test__ / AvValidator.email.spec.js View on Github external
import {AvValidator} from 'availity-reactstrap-validation';

const fn = AvValidator.email;

describe('Email Validation', () => {
  it('should not require a value', () => {
    expect(fn('')).to.be.true;
  });

  it('should return true for a valid email', () => {
    expect(fn('evan.sharp@availity.com')).to.be.true;
    expect(fn('evan.sharp+more-things@availity.com')).to.be.true;
    expect(fn('evan.sharp@availity.com.co')).to.be.true;
    expect(fn('evan.sharp@development.availity.com')).to.be.true;
    expect(fn('Evan.Sharp@Availity.com')).to.be.true;
  });

  it('should return false for an invalid email', () => {
    expect(fn('evan.sharp@availity')).to.be.false;
github Availity / availity-reactstrap-validation / __test__ / AvValidator.match.spec.js View on Github external
import {AvValidator} from 'availity-reactstrap-validation';

const fn = AvValidator.match;
const now = new Date();
const context = {
  field1: "",
  field2: "something",
  field3: now,
  field4: 4,
  field5: {value: "something"},
};

describe('Match Validation', () => {
  it('should not require a value', () => {
    expect(fn('')).to.be.true;
  });

  it('should return false by default when fields do not match', () => {
    expect(fn('something', context, {value: 'field1'})).to.be.false;
github Availity / availity-reactstrap-validation / __test__ / AvValidator.max.spec.js View on Github external
import {AvValidator} from 'availity-reactstrap-validation';

const fn = AvValidator.max;

describe('Max Validation', () => {
  it('should not require a value', () => {
    expect(fn('')).to.be.true;
  });

  it('should accept input array as an alias for maxChecked', () => {
    expect(fn(undefined, undefined, {value: 1}, {value: ['a', 'b']})).to.be.false;
    expect(fn(undefined, undefined, {value: 2}, {value: ['a']})).to.be.true;
  });

  it('should return true if the value is less than the constraint', () => {
    expect(fn(1, undefined, {value: 5})).to.be.true;
  });

  it('should true if the value is the same as than the constraint', () => {
github Availity / availity-reactstrap-validation / __test__ / AvValidator.maxlength.spec.js View on Github external
it('have an alias of maxLength', () => {
    expect(fn).to.equal(AvValidator.maxLength);
  });