Giter Club home page Giter Club logo

Comments (4)

stathissideris avatar stathissideris commented on July 28, 2024

Maybe something like:

(defn coerce!
  "Like coerce, but will call s/assert on the result, making it throw an error if value
  doesn't comply after coercion."
  [k x]
  (let [coerced (coerce k x)]
    (cond (simple-keyword? k)
          coerced
          (s/valid? k coerced)
          coerced
          :else
          (throw (ex-info "Failed to coerce value" {:spec  k
                                                    :value x})))))

from spec-coerce.

wilkerlucio avatar wilkerlucio commented on July 28, 2024

@stathissideris thanks, that sounds a reasanable behavior, I just released 1.0.0-alpha8 using a more tolerant behavior for coerce! so it will not throw on simple keywords.

Closed by ab2867c

from spec-coerce.

stathissideris avatar stathissideris commented on July 28, 2024

Many thanks for doing this and for your prompt response! I and my colleagues are using spec-coerce in a couple of projects and we're finding very useful!

from spec-coerce.

wilkerlucio avatar wilkerlucio commented on July 28, 2024

Nice, glad to hear that. :)

from spec-coerce.

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.