Code Monkey home page Code Monkey logo

Comments (12)

benasher44 avatar benasher44 commented on May 20, 2024 1

I'm also happy to do the work here. I mostly just want to agree on the idea & API before jumping in :)

from connectivity.

benasher44 avatar benasher44 commented on May 20, 2024 1

Sounds good to me! Will take a crack at this soon

from connectivity.

benasher44 avatar benasher44 commented on May 20, 2024 1

Actually I don't see tests anywhere… would you like some tests added?

from connectivity.

rwbutler avatar rwbutler commented on May 20, 2024 1

Thanks - I've merged that in now. Apologies, yes you are correct, I've been meaning to add some tests for a long time now but had been a little rushed off my feet. Now that you've reminded me to come back to this, I'll start adding some too.

from connectivity.

rwbutler avatar rwbutler commented on May 20, 2024 1

I've just created a release 3.2.0 containing your PR πŸ‘πŸ»

from connectivity.

benasher44 avatar benasher44 commented on May 20, 2024

One way to do this without over-complicating the API would be to allow setting a block that gets called (with the URL that was requested and the response) to perform custom validation of all URLs. This block could return a result like this:

enum CustomValidationResult {
    /// response for the url was validated successfully
    case valid

    /// response for the url was determined to be invalid
    case invalid

    /// perform the default / non-custom validation
    case performDefaultValidation
}

from connectivity.

rwbutler avatar rwbutler commented on May 20, 2024

Hi Ben,

Sorry for the delay in getting back to you - thanks for the suggestion :) I've been having a think about this as well and one of the things I'm a little concerned about is the main file / class length is beginning to approach a length that will trigger linter warnings so it might be an idea to create a protocol e.g. ConnectivityResponseValidation and then enable users to create a custom response validator which conforms to the protocol - this would avoid increasing the file / class length. A property e.g. responseValidator could be set on the Connectivity object enabling users to set their own implementation as the validator to be used. How does this sound?

from connectivity.

benasher44 avatar benasher44 commented on May 20, 2024

Sounds good to me! Similar behavior though? Custom validator can opt to handle the response or pass it back to the default validation to handle?

from connectivity.

rwbutler avatar rwbutler commented on May 20, 2024

Great πŸ‘πŸ» I'd be happy with that solution.

from connectivity.

rwbutler avatar rwbutler commented on May 20, 2024

One thing I thought of was - currently ConnectivityResponseValidator switches behavior based on the response validation mode passed in to the initializer (it will use string matching or regex). It might be a nice idea to split these out into separate validators conforming to the ConnectivityResponseValidation protocol i.e. one for string matching, one for regex etc. That way in a custom validator you would be able to invoke the response validator of your choice depending on the URL you receive. If the only option is to fallback to a single default validator then the behavior of the default validator wouldn't be able to change per URL because the settings remain the same (the validation mode would remain unchanged for the default validator). Having different validators conforming to the protocol would also mean that the user could make use of any of these simply by assigning the relevant validator to the responseValidator property.

from connectivity.

benasher44 avatar benasher44 commented on May 20, 2024

The initial PR is here: benasher44#1. I'll open a fresh one against this repo with tests once we discuss and also resolve what to do about #27.

from connectivity.

benasher44 avatar benasher44 commented on May 20, 2024

Awesome thanks!

from connectivity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.