Johan Lundström

Results 6 comments of Johan Lundström

This is my improvement to @tak1n's and @anmacagno's solutions: ```ruby Dry::Validation.register_macro(:contract) do |macro:| contract_instance = macro.args[0] contract_result = contract_instance.(value) unless contract_result.success? # Generate a message string instead of adding a...

Updated variant, now with proper error message nesting. Full solution: ```ruby # Use it like this: # # MyContract = Dry::Validation.Contract do # params do # # for a hash:...

For what it's worth, this was very unexpected behavior _to me_: ```ruby class A < Dry::Struct attribute :id, Types::Strict::Integer attribute :type, Types::Strict::String attribute :name, Types::Strict::String end class B < Dry::Struct...

Thank you for the context @flash-gordon 🙏. And thanks for the suggestion. I solved our case with constrained types: ``` Types::Strict::String.constrained(eql: 'my_type') ```

I managed to get some code working now that does what I want it to (I think it's correct at least), but it feels a bit hacky and I'm not...

Here is how a change to `GattConnection.connect()` to make it fail fast could look like: https://github.com/Beepiz/BleGattCoroutines/compare/main...johanlunds:johanlunds-connect-change ```diff - isConnectedFlow.first { connected -> connected } + + // Alternative #1: Use...