yup#SchemaOf TypeScript Examples

The following examples show how to use yup#SchemaOf. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BillingForm.tsx    From storefront with MIT License 6 votes vote down vote up
validationSchema: SchemaOf<Omit<CustomerAddressInput, 'overwrite'>> = object({
  address1: string().label('Street address').max(100).required(),
  address2: string().min(0).max(254).nullable(),
  city: string().label('City').max(25).required(),
  company: string().label('Company').min(0).max(35).nullable(),
  country: mixed().label('Country').oneOf(Object.values(CountriesEnum)).required(),
  email: string().label('Email').email().min(11).max(254).required(),
  firstName: string().label('First name').max(35).required(),
  lastName: string().label('Last name').max(35).required(),
  phone: string().label('Phone number').min(10).max(15).required(),
  postcode: string().label('Postcode').min(2).max(9).required(),
  state: string().label('State').min(0).max(254).nullable(),
})
Example #2
Source File: ShippingForm.tsx    From storefront with MIT License 6 votes vote down vote up
validationSchema: SchemaOf<Omit<CustomerAddressInput, 'email' | 'overwrite' | 'phone'>> =
  object({
    address1: string().label('Street address').max(100).required(),
    address2: string().min(0).max(254),
    city: string().label('City').max(25).required(),
    company: string().label('Company').min(0).max(35),
    country: mixed().label('Country').oneOf(Object.values(CountriesEnum)).required(),
    firstName: string().label('First name').max(35).required(),
    lastName: string().label('Last name').max(35).required(),
    postcode: string().label('Postcode').min(2).max(9).required(),
    state: string().label('State').min(0).max(254),
  })
Example #3
Source File: LoginView.tsx    From storefront with MIT License 5 votes vote down vote up
validationSchema: SchemaOf<LoginMutationVariables> = object({
  password: string().label('Password').min(8).max(35).required(),
  username: string().label('Username').max(35).required(),
})
Example #4
Source File: ContactForm.tsx    From storefront with MIT License 5 votes vote down vote up
validationSchema: SchemaOf<ContactFormData> = object({
  acceptance: boolean().isTrue().required(),
  email: string().label('Email').email().min(11).max(254).required(),
  name: string().label('Name').max(70).required(),
  message: string().label('Message').required(),
  phone: string().label('Phone number').max(15).nullable(),
  subject: string().label('Subject').max(254).nullable(),
})
Example #5
Source File: register.tsx    From storefront with MIT License 5 votes vote down vote up
validationSchema: SchemaOf<RegisterFormData> = object({
  email: string().label('Email').email().min(11).max(254).required(),
  password: string().label('Password').min(8).max(35).required(),
  username: string().label('Username').max(35).required(),
})