Created
September 12, 2020 15:54
-
-
Save arefaslani/9ed1a1d003a5e51d3d0994f1ba11b806 to your computer and use it in GitHub Desktop.
Medium 702687394e3d-cleaning-it-up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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