6.0.1 • Published 9 months ago

@availity/yup v6.0.1

Weekly downloads
311
License
MIT
Repository
github
Last release
9 months ago

yup

Method extensions for the yup

Version

Install

npm install @availity/yup yup --save

Usage

Import the package in the root of your project somewhere and you will have access to all of the provided yup methods.

import '@availity/yup';
import * as yup from 'yup';

const schema = yup.string().dateFormat('MM/DD/YYYY');

schema.isValid('12-12-2012');

Table of Contents

Methods


isRequired String,Array,Number

Parameters

  • required - boolean. Optional. Whether or not the given string is required. Default: true
  • message - string. Optional. Custom error message when invalid. Default: This Field is Required.

Example

yup.string().isRequired();
yup.string().isRequired(true, 'Custom Error Message');
yup.number().isRequired();
yup.array().isRequired();

Additional Schemas


dateRange

Evaluates a date range object.

Parameters

  • options - object. optional. Range Options.
    • format - string. optional. The format to parse the dates with.
    • startKey - string. optional. The key for the start date. Default: startDate
    • endKey - string. optional. The key for the end date. Default: endDate
  • message - string. Optional. Custom error message when invalid. Default: "Date Range is invalid."

Example

const schema = yup.dateRange({
    min: '07/04/2012',
    max: '07/12/2012',
});

schema.isValid({
    startdate: '07/05/2012',
    endDate: '07/10/2012',
});

methods

between

Accepts range of dates the date range can fall between.

parameters

  • minDate - string. required. The minimum date.
  • maxDate - string. required. The max date.
  • message - string. Optional. Custom error message when invalid. Default: "Date Range must be between XX/XX/XXXX and XX/XX/XXXX."

example

const schema = yup.dateRange().between('12/01/2012', '12/10/2012');

schema.isValid({
    startDate: '12/02/2012',
    endDate: '12/03/2012',
}); // valid

min

Accepts date the date range must start after.

parameters

  • minDate - string. required. The minimum date.
  • message - string. Optional. Custom error message when invalid. Default: "Date Range must start after XX/XX/XXXX"

example

const schema = yup.dateRange().min('12/01/2012');

schema.isValid({
    startDate: '12/02/2012',
    endDate: '12/03/2012',
}); // valid

max

Accepts date, the date range must start before.

parameters

  • maxDate - string. required. The max date.
  • message - string. Optional. Custom error message when invalid. Default: "Date Range must start before XX/XX/XXXX"

example

const schema = yup.dateRange().max('12/10/2012');

schema.isValid({
    startDate: '12/02/2012',
    endDate: '12/03/2012',
}); // valid

date

Overrides the default date yup object and accepts a string or dayjs object instead. See Date for min and max

Methods

between

Takes an object of dates the given date must fall between

parameters

  • minDate - string. required. The minimum date.
  • maxDate - string. required. The max date.
  • message - string. Optional. Custom error message when invalid. Default: "Date must be between XX/XX/XXXX and XX/XX/XXXX."

example

const schema = yup.date().between('12/01/2012', '12/10/2012');

schema.isValid('12/02/2012'); // valid
6.0.1

9 months ago

6.0.0

12 months ago

5.1.7

12 months ago

5.1.6

1 year ago

5.1.5

1 year ago

5.1.4

1 year ago

5.1.3

2 years ago

1.0.0

2 years ago

5.1.2

3 years ago

5.1.1

3 years ago

5.1.0

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.1.1-alpha.2

4 years ago

4.2.0

4 years ago

4.1.0

4 years ago

3.2.1

4 years ago

4.0.0

4 years ago

3.2.0

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.11

4 years ago

3.0.9

4 years ago

3.0.10

4 years ago

3.0.9-alpha.15

4 years ago

3.0.8

5 years ago

3.0.8-alpha.4

5 years ago

3.0.8-alpha.3

5 years ago

3.0.7

5 years ago

3.0.6

5 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.10

5 years ago

2.0.9

5 years ago

2.0.3

5 years ago

2.0.5

5 years ago

2.0.8

5 years ago

2.0.0

5 years ago

1.3.5-alpha.18

5 years ago

1.3.4

5 years ago

1.3.3

6 years ago

1.3.2

6 years ago

2.0.0-alpha.16

6 years ago

2.0.0-alpha.8

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1-alpha.615

6 years ago

1.0.1-alpha.613

6 years ago

1.0.1-alpha.612

6 years ago

1.0.1-alpha.611

6 years ago

1.0.1-alpha.610

6 years ago