5.1.5 • Published 2 months ago

@availity/yup v5.1.5

Weekly downloads
311
License
MIT
Repository
github
Last release
2 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
5.1.5

2 months ago

5.1.4

2 months ago

5.1.3

8 months ago

1.0.0

8 months ago

5.1.2

2 years ago

5.1.1

2 years ago

5.1.0

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

4.1.1-alpha.2

2 years ago

4.2.0

2 years ago

4.1.0

2 years ago

3.2.1

2 years ago

4.0.0

2 years ago

3.2.0

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.11

3 years ago

3.0.9

3 years ago

3.0.10

3 years ago

3.0.9-alpha.15

3 years ago

3.0.8

4 years ago

3.0.8-alpha.4

4 years ago

3.0.8-alpha.3

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.10

4 years ago

2.0.9

4 years ago

2.0.3

4 years ago

2.0.5

4 years ago

2.0.8

4 years ago

2.0.0

4 years ago

1.3.5-alpha.18

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

2.0.0-alpha.16

4 years ago

2.0.0-alpha.8

4 years ago

1.3.1

4 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1-alpha.615

5 years ago

1.0.1-alpha.613

5 years ago

1.0.1-alpha.612

5 years ago

1.0.1-alpha.611

5 years ago

1.0.1-alpha.610

5 years ago