Coder Social home page Coder Social logo

Comments (9)

SunnyMagadan avatar SunnyMagadan commented on August 28, 2024

Hi, @solnic and @AMHOL
I would like to contribute into your project. I like the idea and see it like a clean and promising replacement for activemodel validations. I've already started playing around with this feature and made some progress there. Please let me know if you are interested in any help here.

from dry-validation.

AMHOL avatar AMHOL commented on August 28, 2024

@SunnyMagadan had a look at your branch and it all looks good to me, if you submit a pull request @solnic can take a look/merge it. Always good to see people taking an interest/helping out, thanks. 😄

from dry-validation.

SunnyMagadan avatar SunnyMagadan commented on August 28, 2024

🙇 Great! Keep doing.

from dry-validation.

SunnyMagadan avatar SunnyMagadan commented on August 28, 2024

@solnic I have one question regarding this feature. How do you plan to deal with optional? Right now it uses Rule::Key with Implication under the hood https://github.com/dryrb/dry-validation/blob/master/lib/dry/validation/schema/definition.rb#L10. Also InputTypeCompiler uses :key for visit and or implication https://github.com/dryrb/dry-validation/blob/master/lib/dry/validation/input_type_compiler.rb#L57. We need to distinguish optional key and optional attr somehow.

from dry-validation.

solnic avatar solnic commented on August 28, 2024

@SunnyMagadan there is no such thing as an optional attribute, an optional key means a hash may, or may not include a given key. When we talk about validating a model, it means it does have attribute readers for specified attributes. In this case, saying attr(:foo) means a model must implement foo reader. You can just skip this for attributes, since an attr reader will return nil even when the ivar was never set, so one could easily write attr(:foo) { |foo| foo.none? | foo.int? } etc.

from dry-validation.

solnic avatar solnic commented on August 28, 2024

BTW feel free to open a PR early, even when it's not finished. We can collaborate on changsets easily etc :)

from dry-validation.

SunnyMagadan avatar SunnyMagadan commented on August 28, 2024

True. It doesn't make sense to have optional attributes. Thank you. I'll open WIP PR soon. :)
Also, I've found that this feature requires changes in dry-data, because current version of InputTypeCompiler based on it and uses schema conversion into hash type. I see that dry-data supports struct, but it requires to define a separate class for this. This is not very efficient for cases when we need to define schema on the fly.

from dry-validation.

solnic avatar solnic commented on August 28, 2024

@SunnyMagadan let's focus on pure schema first w/o coercions. I need to think how to tackle this on the dry-data side. My initial thinking is that we don't want coercions on dry-validation side when you're validating an model, I would say the model should handle coercions instead.

from dry-validation.

SunnyMagadan avatar SunnyMagadan commented on August 28, 2024

This issue can be closed since corresponding PR was already merged.

from dry-validation.

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.