{"action":"created","issue":{"url":"https://api.github.com/repos/apotonick/representable/issues/134","labels_url":"https://api.github.com/repos/apotonick/representable/issues/134/labels{/name}","comments_url":"https://api.github.com/repos/apotonick/representable/issues/134/comments","events_url":"https://api.github.com/repos/apotonick/representable/issues/134/events","html_url":"https://github.com/apotonick/representable/issues/134","id":65487802,"number":134,"title":"feature: 'required' properties","user":{"login":"grepory","id":356446,"avatar_url":"https://avatars.githubusercontent.com/u/356446?v=3","gravatar_id":"","url":"https://api.github.com/users/grepory","html_url":"https://github.com/grepory","followers_url":"https://api.github.com/users/grepory/followers","following_url":"https://api.github.com/users/grepory/following{/other_user}","gists_url":"https://api.github.com/users/grepory/gists{/gist_id}","starred_url":"https://api.github.com/users/grepory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grepory/subscriptions","organizations_url":"https://api.github.com/users/grepory/orgs","repos_url":"https://api.github.com/users/grepory/repos","events_url":"https://api.github.com/users/grepory/events{/privacy}","received_events_url":"https://api.github.com/users/grepory/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-03-31T16:11:52Z","updated_at":"2015-04-02T16:52:22Z","closed_at":null,"body":"I'm looking at using Representable for modeling configuration files with required fields and coercion for validation. Is it acceptable to add a boolean required option to decorators that causes render/parse failure if the field is missing?\r\n\r\nI'm currently working on implementing this just for my project, but thought it may be useful to others and makes a little sense to live inside the library? Or an extension to the core library? Thoughts/suggestions?\r\n\r\n<3 representable thanks so much."},"comment":{"url":"https://api.github.com/repos/apotonick/representable/issues/comments/88973206","html_url":"https://github.com/apotonick/representable/issues/134#issuecomment-88973206","issue_url":"https://api.github.com/repos/apotonick/representable/issues/134","id":88973206,"user":{"login":"apotonick","id":10406,"avatar_url":"https://avatars.githubusercontent.com/u/10406?v=3","gravatar_id":"","url":"https://api.github.com/users/apotonick","html_url":"https://github.com/apotonick","followers_url":"https://api.github.com/users/apotonick/followers","following_url":"https://api.github.com/users/apotonick/following{/other_user}","gists_url":"https://api.github.com/users/apotonick/gists{/gist_id}","starred_url":"https://api.github.com/users/apotonick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apotonick/subscriptions","organizations_url":"https://api.github.com/users/apotonick/orgs","repos_url":"https://api.github.com/users/apotonick/repos","events_url":"https://api.github.com/users/apotonick/events{/privacy}","received_events_url":"https://api.github.com/users/apotonick/received_events","type":"User","site_admin":false},"created_at":"2015-04-02T16:52:22Z","updated_at":"2015-04-02T16:52:22Z","body":"Hey @grepory, the \"model that has both representer and contract\" is exactly what an `Operation` does in Trailblazer. Here, every concern (e.g. deserialisation, validation, etc.) is handled with different objects.\r\n\r\nHowever, Reform is already capable of deserialising JSON instead of a hash, by applying the above outlined pattern internally. \r\n\r\nAs far as I can see, you're not interested in deserialisation, it looks like you only need rendering. You basically would do the following in your app (without a Trailblazer operation).\r\n\r\n```ruby\r\nclass Thing::Contract\r\n  property :title\r\n\r\n  validates :title, presence: true\r\nend\r\n\r\ncontract = Thing::Contract.new(thing)\r\ncontract.validate\r\ncontract.to_json\r\n```\r\nIs that basically what you're after?"}}