Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RxSwiftに対応したバリデーションをGenericなProtocolで実装してみた / Generic Validation Protocol with RxSwift

Yuto Yazaki
February 28, 2019

RxSwiftに対応したバリデーションをGenericなProtocolで実装してみた / Generic Validation Protocol with RxSwift

Yuto Yazaki

February 28, 2019
Tweet

More Decks by Yuto Yazaki

Other Decks in Programming

Transcript

  1. 3Y4XJGUʹରԠͨ͠όϦσʔγϣϯΛ (FOFSJDͳ1SPUPDPMͰ࣮૷ͯ͠Έͨ QPUBUPUJQT
 ໼㟒༤ਓ:B[BLJ:VUP

  2. ࣗݾ঺հ w ͓͍͍͠ʂΛ࡞ΔϨγϐಈըϝσΟΞʮNPHVOBʯͷJ04ΤϯδχΞ w ৽ଔ೥໨✨ w ֶੜ࣌୅ʹษڧձӡӦͯ͠·ͨ͠ʢࣾձਓʹͳͬͯൃද͸ॳΊͯʣ άϦʔגࣜձࣾ ޿ࠂɾϝσΟΞࣄۀຊ෦ϥΠϑελΠϧࣄۀ෦ ϝσΟΞάϧʔϓ։ൃνʔϜ

    ໼㟒༤ਓ:B[BLJ:VUP
  3. 3Y4XJGUʹରԠͨ͠όϦσʔγϣϯΛ (FOFSJDͳ1SPUPDPMͰ࣮૷ͯ͠Έͨ

  4. 3Y4XJGUʹରԠͨ͠όϦσʔγϣϯΛ࡞Γ͍ͨ w Ϣʔβͷೖྗ಺༰ΛόϦσʔγϣϯ͍ͨ͠ w ྫOจࣈҎ಺ ෆਖ਼ͳॻࣜͷνΣοΫ FUD w Τϥʔͷཧ༝Λఏࣔͯ͠Ϣʔβʹमਖ਼ͯ͠΋Β͏ w

    3Y4XJGUͰόΠϯυ͍ͤͨ͞ w δΣωϦΫεͰ͍͍ײ͡ʹ w όϦσʔγϣϯ͢Δ044ϥΠϒϥϦ͸͋Δ͕ w ϥΠϒϥϦಋೖ͢Δ΄ͲͰ΋ͳ͍͠ w 3Y4XJGUʹରԠͯ͠ͳ͍͠ (FOFSJDͳ1SPUPDPMͰ 3Y4XJGUʹରԠͨ͠7BMJEBUPSΛ࣮૷͠Α͏
  5. ׬੒Πϝʔδ Ϣʔβͷೖྗͨ͠จࣈྻ͕ ༗ޮͳ஋Ͱ͋Ε͹ ૹ৴ϘλϯΛԡͤΔΑ͏ʹ͢Δ

  6. 7BMJEBUPSϓϩτίϧ ValueTypeɿόϦσʔγϣϯ͢Δ஋ͷܕ ErrorType ɿෆਖ਼ͳ஋ͷ৔߹ͷΤϥʔ validate() ɿόϦσʔγϣϯ݁ՌΛฦ͢

  7. 7BMJEBUJPO3FTVMU όϦσʔγϣϯͷਖ਼ޡΛද͢FOVN

  8. 7BMJEBUPSͷ࣮૷ྫ Ϣʔβ໊ͷೖྗཝΛ૝ఆͯ͠ ΤϥʔΛఆٛ͢Δ όϦσʔγϣϯͷϩδοΫΛॻ͘ 4USJOH Λೖྗ஋ʹ͢Δ

  9. 7BMJEBUPSͷ࢖༻ྫ ୯ମͰ͸ಈ͘Α͏ʹͳͬͨ ͜ΕΛ3Y4XJGUʹରԠͤ͞Δ

  10. 3Y4XJGUͷ0CTFSWBCMF5ZQFʹ WBMJEBUFΦϖϨʔλΛੜ΍͢ Ҿ਺ʹ7BMJEBUPSΛ౉ͯ͠ɺ ετϦʔϜʹྲྀΕ͖ͯͨ஋ΛόϦσʔγϣϯ͠ɺ ݁ՌΛ7BMJEBUJPO3FTVMUܕͰฦ͢ɻ

  11. ׬੒

  12. ࢖ͬͯΈΔ όϦσʔγϣϯʹҾ͔͔ͬͬͨΒˠΤϥʔ಺༰Λදࣔ ༗ޮͳ஋Ͱ͋Ε͹ˠ4VCNJUϘλϯ͕ԡͤΔΑ͏ʹͳΔ

  13. None
  14. ·ͱΊ w όϦσʔγϣϯ͢ΔϓϩτίϧΛఆٛ w Ϣχοτςετ͕ॻ͖΍͍͢ w 3Y4XJGUʹόϦσʔγϣϯͷΦϖϨʔλΛੜ΍͢ w γϯϓϧͳهड़Ͱݟ௨͠ͷΑ͍ίʔυʹͳΔ w

    δΣωϦΫεͷษڧʹͳͬͨ w αϯϓϧίʔυ w IUUQTHJUIVCDPNZVUPZB[BLJ3Y7BMJEBUJPO4BNQMF
  15. 5IBOLT