How to use the yup.array 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 First-Peoples-Cultural-Council / fv-web-ui / frontend / app / assets / javascripts / views / pages / explore / dialect / create / Audio / validation.js View on Github external
'fvm:source': t.list(t.String),
*/
import copy from './internationalization'

const validForm = yup.object().shape({
  'dc:title': yup
    .string()
    .label(copy.name)
    .required(copy.validation.name),
  'dc:description': yup.string(),
  // file: yup.array().min(1, 'gotta provide a file!'),
  file: yup.array(),
  'fvm:shared': yup.boolean(),
  'fvm:child_focused': yup.boolean(),
  'fvm:source': yup.array().of(yup.string()),
  'fvm:recorder': yup.array().of(yup.string()),
})

export const toParse = [/^fvm:source/, /^fvm:recorder/]
export default validForm
github jquense / react-formal / test / FieldArray.spec.js View on Github external
describe('FieldArray', () => {
  let schema = object({
    colors: array()
      .of(
        object({
          name: string().required(),
          hexCode: string().required(),
        })
      )
      .default(() => [{ name: 'red', hexCode: '#ff0000' }]),
  })

  class ColorList extends React.Component {
    remove(index) {
      this.props.arrayHelpers.remove(this.props.value[index])
    }

    render() {
      const { value, name } = this.props
github ahrbil / TDI-Exchange / packages / web / src / components / form-validation-schema / index.js View on Github external
import * as Yup from "yup";

import { FILE_SIZE, FILE_TYPES } from "../../constants";

const validationSchema = Yup.object().shape({
  title: Yup.string()
    .min(3, "too short for title")
    .required("*Title is required"),
  description: Yup.string()
    .min(8, "too short for description")
    .required("*Description is required"),
  location: Yup.string()
    .min(8, "too short for location address")
    .required("*Location is required"),
  tags: Yup.array()
    .max(10, "Only 10 tags are allowed")
    .required("Provide at least one tag"),
  file: Yup.mixed()
    .required("*Avatar image is required")
    .test(
      "fileSize",
      "Image too large, max 8mb",
      value => value && value.size <= FILE_SIZE
    )
    .test(
      "fileFormat",
      "Images only",
      value => value && FILE_TYPES.includes(value.type)
    )
});
github GenesisVision / web-client / packages / manager / src / pages / create-fund / components / create-fund-settings / create-fund-settings.validators.ts View on Github external
export const assetsShape = (t: i18next.TFunction) => {
  return array()
    .test(
      CREATE_FUND_FIELDS.assets,
      t("manager.create-fund-page.settings.validation.assets-share"),
      (val: FundAssetPart[]) => {
        return val.reduce((acc, next) => acc + next.percent, 0) == 100;
      }
    )
    .required(t("manager.create-fund-page.settings.validation.assets-count"))
    .min(2, t("manager.create-fund-page.settings.validation.assets-count"));
};
github danielbayerlein / dashboard / components / widgets / jenkins / job-health.js View on Github external
const jenkinsKpiColor = ({ theme, value }) => {
  if (value < 70) return theme.palette.errorColor
  if (value >= 70 && value < 90) return theme.palette.warnColor
  return theme.palette.successColor
}

const Kpi = styled.span`
  color: ${jenkinsKpiColor};
  font-weight: 700;
  font-size: 20px;
`

const schema = object().shape({
  url: string().url().required(),
  jobs: array(object({
    label: string().required(),
    path: string().required(),
    branch: string()
  })).required(),
  interval: number(),
  title: string(),
  authKey: string()
})

export default class JenkinsJobHealth extends Component {
  static defaultProps = {
    interval: 1000 * 60 * 5,
    title: 'Job Health'
  }

  state = {
github danielbayerlein / dashboard / components / widgets / bitbucket / pull-request-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({
  url: yup.string().url().required(),
  project: yup.string().required(),
  repository: yup.string().required(),
  interval: yup.number(),
  title: yup.string(),
  users: yup.array().of(yup.string()),
  authKey: yup.string()
})

export default class BitbucketPullRequestCount extends Component {
  static defaultProps = {
    interval: 1000 * 60 * 5,
    title: 'Bitbucket PR Count',
    users: []
  }

  state = {
    count: 0,
    error: false,
    loading: true
  }
github Nike-Inc / referee / packages / client / src / validation / tocValidators.ts View on Github external
import { string, object, array } from 'yup';
import { ValidationResultsWrapper } from '../domain/Referee';

const tocSchema = object().shape({
  home: string()
    .trim()
    .required(),
  table_of_contents: array()
    .of(
      object().shape({
        directory: string()
          .trim()
          .required(),
        pages: array().of(
          object().shape({
            filename: string()
              .trim()
              .required(),
            display_name: string().trim()
          })
        )
      })
    )
    .required(),
github openshift / console / frontend / packages / dev-console / src / components / pipelines / pipeline-form / pipelineForm-validation-utils.ts View on Github external
default: yup.string().required('Required'),
    }),
  ),
});

export const startPipelineSchema = yup.object().shape({
  resources: yup.array().of(
    yup.object().shape({
      name: yup.string().required('Required'),
      type: yup.string().required('Required'),
      resourceRef: yup.object().shape({
        name: yup.string().required('Required'),
      }),
    }),
  ),
  parameters: yup.array().of(
    yup.object().shape({
      name: yup.string().required('Required'),
      description: yup.string(),
      default: yup.string().required('Required'),
    }),
  ),
});
github elifesciences / elife-xpub / packages / component-submission / client / components / steps / Submission / schema.js View on Github external
import * as yup from 'yup'

const submissionPageSchema = {
  meta: yup.object().shape({
    title: yup.string().required('Title is required'),
    articleType: yup.string().required('Article type is required'),
    subjects: yup
      .array()
      .min(1, `Choose at least 1 subject area`)
      .max(2, `No more than 2 subject areas`)
      .required('Subject area(s) required'),
  }),
  previouslyDiscussed: yup
    .string()
    .notOneOf(['', undefined], 'Please describe your previous interaction')
    .nullable(),
  previouslySubmitted: yup.array(
    yup
      .string()
      .notOneOf([''], 'Article title is required')
      .nullable(),
  ),
  firstCosubmissionTitle: yup
github worldsibu / convector-identity-patterns / packages / participant-cc / dist / src / participant.model.js View on Github external
return _this;
    }
    tslib_1.__decorate([
        convector_core_model_1.ReadOnly()
    ], Participant.prototype, "type", void 0);
    tslib_1.__decorate([
        convector_core_model_1.ReadOnly(),
        convector_core_model_1.Required(),
        convector_core_model_1.Validate(yup.string())
    ], Participant.prototype, "name", void 0);
    tslib_1.__decorate([
        convector_core_model_1.ReadOnly(),
        convector_core_model_1.Validate(yup.string())
    ], Participant.prototype, "msp", void 0);
    tslib_1.__decorate([
        convector_core_model_1.Validate(yup.array(exports.x509Identities))
    ], Participant.prototype, "identities", void 0);
    return Participant;
}(convector_core_model_1.ConvectorModel));
exports.Participant = Participant;