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

Document how to validate nested objects #13

Open
boosh opened this issue May 21, 2021 · 1 comment
Open

Document how to validate nested objects #13

boosh opened this issue May 21, 2021 · 1 comment

Comments

@boosh
Copy link

boosh commented May 21, 2021

Hi, this library looks great. Does it support validating nested objects? E.g. how could I write a schema to validate the object below?

    {
        name: "",
        about: "",
        location: {
          city: "",
          country: "",
          lat: 0,
          lng: 0
        }
    },

I know I can do this:

  location: {
    required: true,
    object: true,
    customRule: function (location) {
      return (location.city.length > 0) ? true : "Please select a location"
    }
  },

But is there a way of embedding validation rules for city, country, lat, lng in the schema directly?

@Bogatinovski
Copy link

I am also interested whether we can validate nested objects and what would be the right way to do it?

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

2 participants