{"action":"closed","issue":{"url":"https://api.github.com/repos/bluesuncorp/validator/issues/78","labels_url":"https://api.github.com/repos/bluesuncorp/validator/issues/78/labels{/name}","comments_url":"https://api.github.com/repos/bluesuncorp/validator/issues/78/comments","events_url":"https://api.github.com/repos/bluesuncorp/validator/issues/78/events","html_url":"https://github.com/bluesuncorp/validator/issues/78","id":89298048,"number":78,"title":"Add support to validate fields or structs nested within arrays, slices and maps","user":{"login":"joeybloggs","id":8068371,"avatar_url":"https://avatars.githubusercontent.com/u/8068371?v=3","gravatar_id":"","url":"https://api.github.com/users/joeybloggs","html_url":"https://github.com/joeybloggs","followers_url":"https://api.github.com/users/joeybloggs/followers","following_url":"https://api.github.com/users/joeybloggs/following{/other_user}","gists_url":"https://api.github.com/users/joeybloggs/gists{/gist_id}","starred_url":"https://api.github.com/users/joeybloggs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeybloggs/subscriptions","organizations_url":"https://api.github.com/users/joeybloggs/orgs","repos_url":"https://api.github.com/users/joeybloggs/repos","events_url":"https://api.github.com/users/joeybloggs/events{/privacy}","received_events_url":"https://api.github.com/users/joeybloggs/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bluesuncorp/validator/labels/new","name":"new","color":"009800"},{"url":"https://api.github.com/repos/bluesuncorp/validator/labels/priority","name":"priority","color":"e11d21"},{"url":"https://api.github.com/repos/bluesuncorp/validator/labels/review","name":"review","color":"207de5"}],"state":"closed","locked":false,"assignee":{"login":"joeybloggs","id":8068371,"avatar_url":"https://avatars.githubusercontent.com/u/8068371?v=3","gravatar_id":"","url":"https://api.github.com/users/joeybloggs","html_url":"https://github.com/joeybloggs","followers_url":"https://api.github.com/users/joeybloggs/followers","following_url":"https://api.github.com/users/joeybloggs/following{/other_user}","gists_url":"https://api.github.com/users/joeybloggs/gists{/gist_id}","starred_url":"https://api.github.com/users/joeybloggs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeybloggs/subscriptions","organizations_url":"https://api.github.com/users/joeybloggs/orgs","repos_url":"https://api.github.com/users/joeybloggs/repos","events_url":"https://api.github.com/users/joeybloggs/events{/privacy}","received_events_url":"https://api.github.com/users/joeybloggs/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/bluesuncorp/validator/milestones/10","html_url":"https://github.com/bluesuncorp/validator/milestones/Next%20Release%20v5","labels_url":"https://api.github.com/repos/bluesuncorp/validator/milestones/10/labels","id":1152063,"number":10,"title":"Next Release v5","description":"","creator":{"login":"joeybloggs","id":8068371,"avatar_url":"https://avatars.githubusercontent.com/u/8068371?v=3","gravatar_id":"","url":"https://api.github.com/users/joeybloggs","html_url":"https://github.com/joeybloggs","followers_url":"https://api.github.com/users/joeybloggs/followers","following_url":"https://api.github.com/users/joeybloggs/following{/other_user}","gists_url":"https://api.github.com/users/joeybloggs/gists{/gist_id}","starred_url":"https://api.github.com/users/joeybloggs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeybloggs/subscriptions","organizations_url":"https://api.github.com/users/joeybloggs/orgs","repos_url":"https://api.github.com/users/joeybloggs/repos","events_url":"https://api.github.com/users/joeybloggs/events{/privacy}","received_events_url":"https://api.github.com/users/joeybloggs/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":22,"state":"open","created_at":"2015-06-05T20:29:17Z","updated_at":"2015-06-27T18:46:03Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-06-18T13:43:32Z","updated_at":"2015-06-27T18:46:03Z","closed_at":"2015-06-27T18:46:03Z","body":"this was prompted by pull request https://github.com/gin-gonic/gin/pull/224 for @manucorporat\r\n\r\nadd an additional tag called \"dive\", this will let the library know to dive into the array or slice; additionally any validations such as gt=0 that appear after dive can be applied to simple data types, while maintaining the validation on the actual array field before the dive tag.\r\ni.e.\r\n```go\r\ntype Address struct {\r\n    Location string `validate:\"required\"`\r\n}\r\n\r\ntype User struct {\r\n    Addresses    []*Address `validate:\"gt=0,dive\"`           // dive into the array/slice and validate Adress\r\n    WorkingDays  []int      `validate:\"eq=7,dive,eq=0|eq=1\"` // validate there are exactly 7 array items and then dive into int array and validate that each value is either 0 or 1\r\n}\r\n```\r\n\r\nNow the hard part\r\n==============\r\n\r\nNeed to figure out a way to store the errors within the StructErrors and FieldError struct's hierarchy; it's not enough to just throw an error, I need to store the error, what field it was on AND what index of the array or struct it was on so that I may display the error on the actual field within the application using this library ( like it is now )\r\n\r\nit's further complicated by maps, because the key could be of just about any data type\r\n\r\nand even more, what about arrays of arrays [][]int\r\n\r\nAny suggestions are definitely welcome, I will just have to be creative."}}