Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yup schema of an yup-ast definition itself #4

Open
jakelowen opened this issue Jun 23, 2019 · 2 comments
Open

yup schema of an yup-ast definition itself #4

jakelowen opened this issue Jun 23, 2019 · 2 comments

Comments

@jakelowen
Copy link

Amazing library. I've been playing with this concept for a while and your execution is very clean.

This may be very "meta" request, but do you have a ready example of a proper yup.schema of a yup-ast definition itself?

My use case: I'm attempting to validate an object of which a yup-ast definition is one aspect among others.

Example: see the "triggerConditions" line below.

let schema = yup.object().shape({
    name: yup.string(),
    id: yup.string(),
    notes: yup.string(),
    steps: yup
      .array()
      .of(
        yup.object().shape({
          name: yup.string().required(),
          topic: yup.string().required(),
          // triggerConditions is a yup-ast definition
          triggerConditions: yup.array().of(yup.array()),
          extractions: yup.array().of(
            yup.array().of(yup.string()).min(1)
          ).required(),
          required: yup.boolean().required(),
          maxAttempts: yup.number().min(1).positive().required()
        })
      )
      .required()

  });

Should I be more specific than yup.array().of(yup.array()) ?

@avin-kavish
Copy link

Sounds like you need to write a custom validator for yup, to validate the yup-ast format

@tavurth
Copy link
Contributor

tavurth commented Mar 12, 2020

Unfortunately I can't make any changes due to #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants