$30 off During Our Annual Pro Sale. View Details »

dry-validations

 dry-validations

Krzysztof Wawer

September 23, 2016
Tweet

More Decks by Krzysztof Wawer

Other Decks in Programming

Transcript

  1. Krzysztof (Christopher) Wawer
    @wafcio about.me/kwawer

    View Slide

  2. Our API
    • Roda
    • ROM (Ruby Object Mapper)
    • JSON API standard (http://jsonapi.org)

    View Slide

  3. {
    price: 1000
    }
    =>
    {
    price: '1000'
    }
    /\d+/

    View Slide

  4. dry-validation
    Piotr Solnica
    Andy Holland
    http://dry-rb.org/gems/dry-validation/

    View Slide

  5. Community
    • 17 contributors
    • very active Gitter channel
    https://gitter.im/dry-rb/chat
    • v0.10.1
    • used in hanami-validations, reform

    View Slide

  6. Strange and awesome
    things

    View Slide

  7. Predicate Logic
    • and ( & )
    • or ( | )
    Dry::Validation.Schema do
    required(:age) { int? & gt?(18) }
    end

    View Slide

  8. Optional Keys and Values
    {
    age: 30
    }
    {
    name: nil,
    age: 30
    }

    View Slide

  9. Nested data
    {
    name: "John",
    address: {
    street: "Main Street"
    },
    emails: ["[email protected]"]
    }

    View Slide

  10. Shared schema
    Dry::Validation.Schema do
    required(:name).filled
    required(:address).schema(AddressSchema)
    end

    View Slide

  11. dry-validation
    http://dry-rb.org/gems/dry-validation/

    View Slide

  12. Thanks
    @wafcio about.me/kwawer

    View Slide