yup#Lazy TypeScript Examples

The following examples show how to use yup#Lazy. 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: Schema.ts    From gear-js with GNU General Public License v3.0 5 votes vote down vote up
payloadSchema = lazy((value) => {
  if (typeof value === 'object') {
    return object();
  }

  return string().required('This field is required');
})
Example #2
Source File: ClusterDeploymentDetailsStep.tsx    From assisted-ui-lib with Apache License 2.0 5 votes vote down vote up
useDetailsFormik = ({
  clusterDeployment,
  agentClusterInstall,
  agents,
  clusterImages,
  usedClusterNames,
  defaultBaseDomain,
  pullSecret,
}: UseDetailsFormikArgs): [ClusterDetailsValues, Lazy] => {
  const featureSupportLevels = useFeatureSupportLevel();
  const ocpVersions = getOCPVersions(clusterImages);
  const cluster = React.useMemo(
    () =>
      clusterDeployment && agentClusterInstall
        ? getAICluster({
            clusterDeployment,
            agentClusterInstall,
            agents,
          })
        : undefined,
    [agentClusterInstall, clusterDeployment, agents],
  );
  const initialValues = React.useMemo(
    () =>
      getClusterDetailsInitialValues({
        managedDomains: [], // not supported
        cluster,
        ocpVersions,
        baseDomain: defaultBaseDomain,
        pullSecret,
      }),
    [], // eslint-disable-line react-hooks/exhaustive-deps
  );
  const validationSchema = React.useMemo(
    () =>
      getClusterDetailsValidationSchema({
        usedClusterNames,
        featureSupportLevels,
        pullSecretSet: true,
        ocpVersions,
        validateUniqueName: true,
      }),
    [usedClusterNames, ocpVersions, featureSupportLevels],
  );

  return [initialValues, validationSchema];
}