{"action":"created","issue":{"url":"https://api.github.com/repos/gcanti/tcomb/issues/179","repository_url":"https://api.github.com/repos/gcanti/tcomb","labels_url":"https://api.github.com/repos/gcanti/tcomb/issues/179/labels{/name}","comments_url":"https://api.github.com/repos/gcanti/tcomb/issues/179/comments","events_url":"https://api.github.com/repos/gcanti/tcomb/issues/179/events","html_url":"https://github.com/gcanti/tcomb/issues/179","id":131567752,"number":179,"title":"Add support for extending refinements","user":{"login":"gcanti","id":878912,"avatar_url":"https://avatars.githubusercontent.com/u/878912?v=3","gravatar_id":"","url":"https://api.github.com/users/gcanti","html_url":"https://github.com/gcanti","followers_url":"https://api.github.com/users/gcanti/followers","following_url":"https://api.github.com/users/gcanti/following{/other_user}","gists_url":"https://api.github.com/users/gcanti/gists{/gist_id}","starred_url":"https://api.github.com/users/gcanti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gcanti/subscriptions","organizations_url":"https://api.github.com/users/gcanti/orgs","repos_url":"https://api.github.com/users/gcanti/repos","events_url":"https://api.github.com/users/gcanti/events{/privacy}","received_events_url":"https://api.github.com/users/gcanti/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/gcanti/tcomb/labels/discussion","name":"discussion","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-02-05T06:29:48Z","updated_at":"2016-05-05T01:08:18Z","closed_at":null,"body":"Currently only structs can be extended ([docs](https://github.com/gcanti/tcomb/blob/master/docs/API.md#extending-a-struct)):\r\n\r\n```js\r\ntype Mixin = Object | TcombStruct;\r\n\r\nextend(mixins: Mixin | Array<Mixin>, name?: string) => TcombStruct\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/gcanti/tcomb/issues/comments/217051596","html_url":"https://github.com/gcanti/tcomb/issues/179#issuecomment-217051596","issue_url":"https://api.github.com/repos/gcanti/tcomb/issues/179","id":217051596,"user":{"login":"a-s-o","id":6897926,"avatar_url":"https://avatars.githubusercontent.com/u/6897926?v=3","gravatar_id":"","url":"https://api.github.com/users/a-s-o","html_url":"https://github.com/a-s-o","followers_url":"https://api.github.com/users/a-s-o/followers","following_url":"https://api.github.com/users/a-s-o/following{/other_user}","gists_url":"https://api.github.com/users/a-s-o/gists{/gist_id}","starred_url":"https://api.github.com/users/a-s-o/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a-s-o/subscriptions","organizations_url":"https://api.github.com/users/a-s-o/orgs","repos_url":"https://api.github.com/users/a-s-o/repos","events_url":"https://api.github.com/users/a-s-o/events{/privacy}","received_events_url":"https://api.github.com/users/a-s-o/received_events","type":"User","site_admin":false},"created_at":"2016-05-05T01:08:18Z","updated_at":"2016-05-05T01:08:18Z","body":"Hi, when you say extending refinements, would it cover the following use case. That would be great; I run into this many times in domain design but have not come up with a consistent way of handling this. For example:\r\n\r\nSay I have a struct which has some optional properties:\r\n``` \r\nconst PersonContact = t.struct({\r\n  name: PersonName,\r\n  cell: t.maybe(PhoneNumber),\r\n  work: t.maybe(PhoneNumber),\r\n  email: t.maybe(EmailAddress)\r\n});\r\n``` \r\nI would like to enforce that at least 1 of the cell, work and email fields should be provided. So typically, I write a refinement such as:\r\n```\r\nconst PersonContactStrict = t.refinement(PersonContact, function atLeastOne (x) {\r\n  return Boolean(x.cell) || Boolean(x.work) || Boolean(x.email);\r\n});\r\n```\r\nHowever, I would like to reuse the refined PersonContactStrict as a base for other contacts but cannot since refinements cannot be extended, it does not work. \r\n``` \r\nconst CompanyContact =PersonContactStrict.extend({\r\n  role: t.String,\r\n  department: t.maybe(t.String)\r\n});\r\n``` \r\nI end up having first create CompanyContact and then add the strict refinement to both types and sometimes just writing a custom extend function. Giulia, is this what you are trying to implement?"}}