@ra-libs/react
  • CHANGELOG
  • README
  • Home
    • Table of contents
    • common
      • Countries
      • Currencies
    • components
      • Datagrid
      • ResponsiveDatagrid
      • Fields
        • BooleanField
        • ChipField
        • CountryField
        • CurrencyField
        • DateField
        • FileViewerField
        • MaskedNumberField
        • PhoneField
        • ReferenceArrayField
        • ReferenceField
        • RichTextField
        • SelectField
        • TextField
        • TimeField
        • TimelineArrayField
        • TimezoneField
        • TzDateField
        • TzTimeField
      • Inputs
        • CountryInput
        • CurrencyInput
        • DateInput
        • MapsInput
        • MaskedNumberInput
        • MaskedTextInput
        • PhoneInput
        • PlacesTimelineInput
        • TimeInput
        • TimezoneInput
        • TzDateInput
        • TzTimeInput
    • hooks
      • useCountries
      • useCurrencies
      • useScreenSize
    • providers
      • DataProvider
    • services
      • HttpRequest
      • LocalSession
    • validations
      • maxYear
      • minYear
Powered by GitBook
On this page
  • Usage
  • Translation
Edit on GitHub
  1. Home
  2. validations

maxYear

custom validation method to use with DateInput to validate max accepted year

Usage

import { DateInput, maxYear } from '@ra-libs/react';

<DateInput source="<source>" validate={[maxYear(new Date().getFullYear())]} />;

This will set the max acceptable year to the current year.

Translation

Make sure to add the translation key to your i18n provider as follow:

{
  "validation": {
    "maxYear": "max acceptable year is %{year}"
  }
}
PreviousvalidationsNextminYear

Last updated 1 year ago