How to use the availity-reactstrap-validation.AvValidator.date function in availity-reactstrap-validation

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.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');
    });