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

How to apply dependency validation in the same block ? #621

Open
prk2331 opened this issue Jan 2, 2025 · 3 comments
Open

How to apply dependency validation in the same block ? #621

prk2331 opened this issue Jan 2, 2025 · 3 comments

Comments

@prk2331
Copy link

prk2331 commented Jan 2, 2025

@funkyfuture sorry to tag you directly here
but i'm stuck in this from a long.

Split type dependency on cut off date
When split_type is "custom" then "cutoff_date" is required.

data_splitting:
  type: dict
  required: true
  schema:
    split_type:
      type: string
      allowed:
        - train_test
        - k_fold
        - custom
      required: true
    cutoff_date:
      type: string
      regex: "\\d{4}-\\d{2}-\\d{2}"
      required: false
      dependencies:
        split_type:
        - "custom"

Im getting below error

{'data_splitting': [{'cutoff_date': ["depends on these values: {'split_type': ['custom']}"]}]}

@prk2331
Copy link
Author

prk2331 commented Jan 2, 2025

Please guide

@prk2331
Copy link
Author

prk2331 commented Jan 2, 2025

this dependencies will work when you write the dependency for other field level
i mean to say that suppose if we write the "cutoff_date" in parallel to "data_splitting" then and only it will work

data_splitting:
  type: dict
  required: true
  schema:
    split_type:
      type: string
      allowed:
        - train_test
        - k_fold
        - custom
      required: true
cutoff_date:
  type: string
  regex: "\\d{4}-\\d{2}-\\d{2}"
  required: false
  dependencies:
    data_splitting.split_type:
    - "custom"

If field validations are on same block then it wont work as expected

Q2. if suppose user passed in the document
split_type: k_fold
cutoff_date : "2024-09-09"

then how to bypass this validation ? how can i enforce this in the schema only that don't consider cutoff_date validation when split_type is not custom ? (without writing server side validations with functions)

Q3. In this schema how can i enforce the custom Error messages (without writing server side validations with functions)

right now this error is coming
cutoff_date: depends on these values: {'data_splitting.split_type': ['custom']}

i want error like this (For split_type "custom" cutoff_date is required) Human Readable Error

@prk2331
Copy link
Author

prk2331 commented Jan 2, 2025

@funkyfuture please guide on this. What are the best practices on these questions.
i need to implement something on a very urgent basis
and i think my requirement is not for dependencies
When split_type is "custom" then "cutoff_date" is required.

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

1 participant