DavidePastore / Slim-Validation

A validation library for the Slim Framework. It internally uses Respect/Validation.
170 stars 30 forks source link

Multiple objects validation #41

Closed micobg closed 5 years ago

micobg commented 6 years ago

Added possibility to validate multiple identical objects in array using asterisk sidn as a mask. For object like this:

{
  "people": [{
    "name": "Mark",
    "age": 29
  }, {
    "name": "Olga",
    "age": 31
  }]
}

...or this:

{
  "people": {
    "first": {
      "name": "Mark",
      "age": 29
    }, 
    "second": {
      "name": "Olga",
      "age": 31
    }
  }
}

validation rules would be:

[
  'people' => [
    '*' => [
      'name' => v::alnum(),
      'age' => v::numeric()
    ]
  ]
]
DavidePastore commented 6 years ago

Hi @micobg ! Thanks for your effort in this PR. I'd like to ask you a thing before merge it. What do you think about this PR? It should fix the problem using the Respect/Validation native way, without using the special asterisk wildcard. Please, let me know if this PR is different and in which way.

micobg commented 6 years ago

It looks like it doing the same thing. In this case the native way is better decision. ;)