Sha256: 33af6983745ef139d7728be1fefa19f0a12cf49e9d733da37b61db0360c1ffa7
Contents?: true
Size: 1.82 KB
Versions: 5
Compression:
Stored size: 1.82 KB
Contents
# frozen_string_literal: true module ConvenientService module Examples module Standard class RequestParams module Services class ValidateUncastedParams include ConvenientService::Standard::Config attr_reader :id, :format, :title, :description, :tags, :sources step :validate_id, in: :id step :validate_format, in: :format step :validate_title, in: :title step :validate_description, in: :description def initialize(params:) @id = params[:id] @format = params[:format] @title = params[:title] @description = params[:description] @tags = params[:tags] @sources = params[:sources] end private def validate_id return error("ID is NOT present") if Utils::Object.present?(id) return error("ID `#{id}` is NOT a valid integer") unless Utils::Integer.safe_parse(id) success end def validate_format return error("Format `#{format}` is NOT supported, only JSON is allowed") if format != "json" success end def validate_title return error("Title is NOT present") if Utils::Object.present?(title) success end def validate_description return error("Description is NOT present") if Utils::Object.present?(description) success end ## # TODO: # def validate_tags success end ## # TODO: # def validate_sources success end end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems