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

Describe object.pattern #383

Closed
Marsup opened this issue Jul 12, 2014 · 3 comments
Closed

Describe object.pattern #383

Marsup opened this issue Jul 12, 2014 · 3 comments
Assignees
Labels
feature New functionality or improvement
Milestone

Comments

@Marsup
Copy link
Collaborator

Marsup commented Jul 12, 2014

There is nothing in the description from describe about object.pattern.
It should probably be added to the rule array with arg providing the regex and the matching schema.

@arb
Copy link
Contributor

arb commented Jul 31, 2014

@Marsup can you post an example to work with?

@Marsup
Copy link
Collaborator Author

Marsup commented Jul 31, 2014

Considering the sample from Joi :

var schema = Joi.object({
    a: Joi.string()
}).pattern(/\w\d/, Joi.boolean());
console.log(schema.describe());

The current output would be :

{
  type: "object",
  children: {
    a: {
      type: "string",
      invalids: [""]
    }
  }
}

I think an output like this would do :

{
  type: "object",
  children: {
    a: {
      type: "string",
      invalids: [""]
    }
  },
  rules: [{
    name: "pattern",
    arg: {
      regex: /\w\d/,
      schema: {
        type: "boolean"
      }
    }
  }]
}

Basically adding a new rule with the arguments of pattern, with the schema described.
Looks good ?

This is reference to this Lout issue outmoded/lout#57

@arb arb added the discussion label Jul 31, 2014
@hueniverse hueniverse added this to the 4.7.0 milestone Aug 17, 2014
@hueniverse hueniverse self-assigned this Aug 17, 2014
@hueniverse hueniverse added feature New functionality or improvement and removed request labels Sep 19, 2019
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

3 participants