Skip to content

Instantly share code, notes, and snippets.

@arefaslani
Created September 12, 2020 15:54
Show Gist options
  • Save arefaslani/9ed1a1d003a5e51d3d0994f1ba11b806 to your computer and use it in GitHub Desktop.
Save arefaslani/9ed1a1d003a5e51d3d0994f1ba11b806 to your computer and use it in GitHub Desktop.
Medium 702687394e3d-cleaning-it-up
module Posts
class Create
include ApplicationService
ValidationSchema = Dry::Schema.Params do
required(:title).filled(:str?)
optional(:body).maybe(:str?)
end
def execute(params)
create_post(params)
end
def create_post(params)
post = Post.create(params)
Success(post)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment