How to use the yup.string function in yup

To help you get started, we’ve selected a few yup 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 OpenCTI-Platform / opencti / opencti-platform / opencti-front / src / private / components / common / stix_relations / StixRelationEditionOverview.js View on Github external
const stixRelationValidation = (t) => Yup.object().shape({
  weight: Yup.number()
    .typeError(t('The value must be a number'))
    .integer(t('The value must be a number'))
    .required(t('This field is required')),
  first_seen: Yup.date()
    .typeError(t('The value must be a date (YYYY-MM-DD)'))
    .required(t('This field is required')),
  last_seen: Yup.date()
    .typeError(t('The value must be a date (YYYY-MM-DD)'))
    .required(t('This field is required')),
  description: Yup.string(),
  role_played: Yup.string(),
});
github GenesisVision / web-client / src / modules / login / components / login-container / login-form / login-form.validators.js View on Github external
import { emailValidator } from "shared/utils/validators/validators";
import { object, string } from "yup";

const validationSchema = object().shape({
  email: emailValidator,
  password: string().required("Password is required.")
});

export default validationSchema;
github streamr-dev / streamr-platform / app / src / marketplace / validators / index.js View on Github external
const editProduct = () => ({
    id: yup.string().nullable(),
    name: yup.string().required(I18n.t('validation.productName')),
    description: yup.string().required(I18n.t('validation.productDescription')),
    category: yup.string().nullable().required(I18n.t('validation.productCategory')),
    streams: yup.array().of(yup.string()),
    state: yup.string(),
    imageUrl: yup.string(),
})
github danielbayerlein / dashboard / components / widgets / github / issue-count.js View on Github external
import { Component } from 'react'
import fetch from 'isomorphic-unfetch'
import yup from 'yup'
import Widget from '../../widget'
import Counter from '../../counter'
import { basicAuthHeader } from '../../../lib/auth'

const schema = yup.object().shape({
  owner: yup.string().required(),
  repository: yup.string().required(),
  interval: yup.number(),
  title: yup.string(),
  authKey: yup.string()
})

export default class GitHubIssueCount extends Component {
  static defaultProps = {
    interval: 1000 * 60 * 5,
    title: 'GitHub Issue Count'
  }

  state = {
    count: 0,
    error: false,
    loading: true
  }
github Azure / AIPlatform / end-to-end-solutions / Luna / src / Luna.UI / isv_client / src / routes / Products / formUtils / ProductDetailsUtils.ts View on Github external
const versionFormValidator: ObjectSchema = yup.object().shape(
  {
    deploymentName: yup.mixed().notRequired(),
    deploymentVersionList: yup.array(),

    versionName: yup.string()
      .matches(versionNameRegExp,
        {
          message: ErrorMessage.versionName,
          excludeEmptyString: true
        })
      .required("versionName is a required field"),
    productName: yup.string(),
    trainModelApi: yup.string(),
    batchInferenceId: yup.string(),
    deployModelId: yup.string(),
    authenticationType: yup.string(),
    authenticationKey: yup.string(),
    //amlWorkspaceName: yup.mixed().notRequired(),
    amlWorkspaceName: yup.mixed()
    .when('source', {is: (val) => { return val === 'aml_pipelines'}, 
                then: yup.string().required('AMLWorkspace is Required'),
                otherwise: yup.mixed().notRequired()}),
    realTimePredictAPI: yup.string(),
    trainModelId: yup.string(),
    advancedSettings: yup.string().nullable(true),
    selectedVersionName:yup.string(),
    versionSourceType:yup.string(),
    gitUrl:yup.string(),
    gitPersonalAccessToken:yup.string(),
    gitVersion:yup.string(),
    projectFileUrl:yup.string(),
github EQuimper / InStore-a-React-Native-E-Commerce-with-a-Restful-API-in-NodeJS / server / src / modules / address / address.controller.js View on Github external
export const create = async (req, res) => {
  const { data } = req.body;

  const schema = Yup.object().shape({
    street: Yup.string().required(),
    aptNum: Yup.string(),
    postalCode: Yup.string()
      .min(6)
      .required(),
    city: Yup.string().required(),
    province: Yup.string().required(),
    instructions: Yup.string(),
    geo: Yup.object().shape({
      lng: Yup.number().required(),
      lat: Yup.number().required(),
    }),
  });

  try {
    await schema.validate(data);

    const address = await AddressServices.createAddress({
      ...data,
github dappforce / dappforce-subsocial-ui / src / components / blogs / EditBlog.tsx View on Github external
slug: Yup.string()
    .required('Slug is required')
    .matches(SLUG_REGEX, 'Slug can have only letters (a-z, A-Z), numbers (0-9), underscores (_) and dashes (-).')
    .min(SLUG_MIN_LEN, `Slug is too short. Minimum length is ${SLUG_MIN_LEN} chars.`)
    .max(SLUG_MAX_LEN, `Slug is too long. Maximum length is ${SLUG_MAX_LEN} chars.`),

  name: Yup.string()
    .required('Name is required')
    .min(NAME_MIN_LEN, `Name is too short. Minimum length is ${NAME_MIN_LEN} chars.`)
    .max(NAME_MAX_LEN, `Name is too long. Maximum length is ${NAME_MAX_LEN} chars.`),

  image: Yup.string()
    .url('Image must be a valid URL.')
    .max(URL_MAX_LEN, `Image URL is too long. Maximum length is ${URL_MAX_LEN} chars.`),

  desc: Yup.string()
    .max(DESC_MAX_LEN, `Description is too long. Maximum length is ${DESC_MAX_LEN} chars.`)
});