jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <Blacksmoke16> got it down to 300 lines 😬
<oprypin> Blacksmoke16, show it 👏👏👏
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9r1i
<FromGitter> <Blacksmoke16> working on reducing the metadata stuff
<FromGitter> <Blacksmoke16> as thats the bulk of whats left
_whitelogger has joined #crystal-lang
<FromGitter> <Blacksmoke16> prob something with generics
<FromGitter> <Blacksmoke16> yea not actually able to reproduce when i remove the need for the metadata objects :/
deavmi has quit [Ping timeout: 258 seconds]
deavmi has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9r1z got it below 200
<FromGitter> <Blacksmoke16> 180*
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 272 seconds]
ukd1 has joined #crystal-lang
ukd1 has quit [Quit: leaving]
_whitelogger has joined #crystal-lang
sagax has quit [Read error: Connection reset by peer]
sagax has joined #crystal-lang
<FromGitter> <naqvis> @Blacksmoke16 Generic modules are the problem. Believe its outstanding issue and they have proven to cause segfaults. Avoiding them makes program happy ⏎ ⏎ https://play.crystal-lang.org/#/r/9r2h
postmodern has quit [Quit: Leaving]
<FromGitter> <asterite> Daily reminder to avoid generics inheritance until someone comes and fixes that
<FromGitter> <Blacksmoke16> 😭 but whats interesting is there are other ways to not make it do that
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/9r2o like just removing that class_getter at the top :shrug:
<FromGitter> <Blacksmoke16> but fwiw, i dont actually know what that `IvarType` generic exists, im not actually using it
<FromGitter> <Blacksmoke16> why*
<FromGitter> <Blacksmoke16> but regardless, that seems to be working in the full program so 👍 thanks
<FromGitter> <naqvis> 👍
<FromGitter> <naqvis> Generic inheritance is still in fragile state, as Ary confirmed the same via his reminder above :P
<FromGitter> <Blacksmoke16> sadly its always something i find myself wanting to do 😭
<FromGitter> <naqvis> so better to avoid Generic inheritance
<FromGitter> <naqvis> or avoid inheritance at all :D
<FromGitter> <naqvis> never been a fan of inheritance
Elouin has quit [Ping timeout: 246 seconds]
<FromGitter> <Blacksmoke16> it works for for most of what im doing, not sure how you would do it otherwise
<FromGitter> <naqvis> yeah, i see you always push compiler to its limits
<FromGitter> <Blacksmoke16> 😎 *life on the bleeding edge*ha
<FromGitter> <naqvis> 😄 👍
<FromGitter> <Blacksmoke16> In other news, now that thats result this work :p
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f6de8484002c640b5e762ca]
<FromGitter> <naqvis> wow, that's beautiful
<FromGitter> <Blacksmoke16> <3
<FromGitter> <naqvis> so `validate` will return resulset of validation?
<FromGitter> <naqvis> and let user decide to raise or not?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f6de8c6e1dd7c1954951ba7]
<FromGitter> <Blacksmoke16> returns a `ConstraintViolationList`
<FromGitter> <naqvis> voila 👍
<FromGitter> <Blacksmoke16> ill prob make some `ValidationError` that accepts a `ConstraintViolationList` or `ConstraintViolation`
<FromGitter> <naqvis> yeah make sense
<FromGitter> <naqvis> and I assume, these annotation will allow custom messages as well?
<FromGitter> <Blacksmoke16> ```code paste, see link``` ⏎ ⏎ yea [https://gitter.im/crystal-lang/crystal?at=5f6dea220b5f3873c9f0d702]
<FromGitter> <naqvis> awsome 👍
<FromGitter> <Blacksmoke16> can also do this
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f6deaad1c5b0d210ace4285]
<FromGitter> <Blacksmoke16> are placeholders you can use like `{{ value }}`, or `{{ limit }}`, etc depending on the specific constraint
<FromGitter> <naqvis> wowwwwww
<FromGitter> <naqvis> just a thought, will it allow custom validators?
<FromGitter> <naqvis> iirc, some other languages some frameworks does have such feature
<FromGitter> <naqvis> allows developers to use custom validators for complex types or complex validation schemes
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f6dec6c417bf140aa11663e]
<FromGitter> <naqvis> i mean via such mechanism, one can just validate `address` in your above example, without having to annotate `Address`
<FromGitter> <Blacksmoke16> ah i see what you mean, there are also callback validators, that like just invoke a method that you could use to do arbitrary logic that wouldnt be reusable
<FromGitter> <naqvis> that's coool, but that's too complex for dumb person like me :P. Would it be possible to provide some-kind of call-back mechanism? or proc invocation?
<FromGitter> <naqvis> e.g ⏎ ⏎ ```@[Assert::Valid(validator: ->my_dumb_validator(ContextXXX,YYYYY)] ⏎ @address : Address``` [https://gitter.im/crystal-lang/crystal?at=5f6ded3b5efe9467b1160ad9]
<FromGitter> <naqvis> just some random thoughts :P
<FromGitter> <naqvis> > ah i see what you mean, there are also callback validators, that like just invoke a method that you could use to do arbitrary logic that wouldnt be reusable ⏎ ⏎ yeah, I believe i was talking this
<FromGitter> <Blacksmoke16> i can get you an example in a sec, but it would basically just add an annotation to a method that takes the context and payload
<FromGitter> <naqvis> no rush
<FromGitter> <naqvis> annotating a custom validator is great design
<FromGitter> <naqvis> 👍
<FromGitter> <Blacksmoke16> one thing im not a super big fan of is needing to define the custom constraints within the `Athena::Validator::Constraints` namespace
<FromGitter> <naqvis> yeah true
<FromGitter> <naqvis> so giving users ability to define custom validators, would restrict their need for custom constraints
<FromGitter> <naqvis> because constraints are usually generic, its just a validation mechanism which is unique for different cases
<FromGitter> <naqvis> my views ofcourse :P
<FromGitter> <Blacksmoke16> my biggest gripe is how the annotation and constraint are separate things
<FromGitter> <Blacksmoke16> so i need ways to map an annotation to its constraint, and vice versa
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f6df3ebf41f4105e4d849b9]
<FromGitter> <Blacksmoke16> theres also a way to add constraints via code instead of annotations
<FromGitter> <Blacksmoke16> like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f6df4485b75b305ddc4e35b]
<FromGitter> <naqvis> yeah totally agree that annotations should be more than a simple marker as they are now
<FromGitter> <naqvis> like how one define custom annotation in Java
<FromGitter> <Blacksmoke16> and in PHP yea
<FromGitter> <Blacksmoke16> but yea, custom constraint would be the preferred approach as you can document, test, and reuse them
<FromGitter> <Blacksmoke16> but a callback is fine for oneoff stuff
<FromGitter> <naqvis> yeah, true
<FromGitter> <Blacksmoke16> one thing i started doing in this project is include a dedicated module that users can require in their `spec_helper`
<FromGitter> <Blacksmoke16> that has testing utilities
<FromGitter> <Blacksmoke16> of how to test a constraint
<FromGitter> <naqvis> that's cool, so in specs they will act like runtime assertions?
<FromGitter> <Blacksmoke16> it essentially expand to normal spec code, sec
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f6df72cf41f4105e4d853e3]
Elouin has joined #crystal-lang
<FromGitter> <Blacksmoke16> where `instance` is an instance of the struct
<FromGitter> <naqvis> aha, so it will be compile time expansion
<FromGitter> <Blacksmoke16> yea
<FromGitter> <naqvis> but if compile time expansion, how the error line number will match with those macros?
<FromGitter> <Blacksmoke16> :thinking: would it matter?
<FromGitter> <naqvis> if some test failed, it will tell it failed at line number ....
<FromGitter> <naqvis> i mean how developer will correlate that to actual location?
<FromGitter> <Blacksmoke16> if replaced `0` with `nil` the error would be
<FromGitter> <Blacksmoke16> ah i see your point
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f6df84f1c5b0d210ace69a2]
<FromGitter> <Blacksmoke16> is pointing to lib code, but message is prob clear enough :shrug:
<FromGitter> <naqvis> yeah, will work as there isn't good IDE support available yet, but if there is some good support when double clicking on error take dev to specific location, then it will cause inconvenience :P
<FromGitter> <Blacksmoke16> oh wait, `it` has `file`, `line`, and `end_line` arguments i could prob use
<FromGitter> <naqvis> 👍
<FromGitter> <Blacksmoke16> not sure how that work work exactly, but prob worth a shot
<FromGitter> <naqvis> yeah, good to add that info to failure message
alexherbo2 has joined #crystal-lang
<FromGitter> <Blacksmoke16> is a bit better
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f6dfaefb8a99f4519a7eec6]
<FromGitter> <Blacksmoke16> ill take it
<FromGitter> <naqvis> yay 👍
<FromGitter> <Blacksmoke16> didnt fix the one in the detail view, wonder why that is
<FromGitter> <Blacksmoke16> ohh, because thats where the assertion is actually failing
sorcus has quit [Quit: WeeChat 2.9]
<FromGitter> <naqvis> I just skimmed through `validator` code and reason its showing the line number of your shard is because you are calling `fail` there
<FromGitter> <naqvis> as you are generating code at compile time, wouldn't it be good that you raise in shard code base and capture inside the expanded code?
<FromGitter> <Blacksmoke16> yea, i could define like `file_name` methods behind the scenes to at least give that right
<FromGitter> <naqvis> and call fail there, it will show the line number of user spec instead of shard
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f6e00525b75b305ddc50623]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f6e0059efefe620f24ae5fe]
<FromGitter> <Blacksmoke16> tada?
<FromGitter> <naqvis> yay 👍
<FromGitter> <Blacksmoke16> good call, ill get those updated today
<FromGitter> <naqvis> awsome 👍
Elouin4 has joined #crystal-lang
Elouin has quit [Remote host closed the connection]
Elouin4 is now known as Elouin
Human_G33k has quit [Quit: Leaving]
HumanG33k has joined #crystal-lang
DTZUZU_ has joined #crystal-lang
DTZUZU has quit [Ping timeout: 272 seconds]
<FromGitter> <Blacksmoke16> done 👍
<FromGitter> <naqvis> 👍
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 272 seconds]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
DTZUZU has joined #crystal-lang
DTZUZU_ has quit [Ping timeout: 264 seconds]
alexherbo2 has quit [Ping timeout: 240 seconds]
sorcus has joined #crystal-lang
<FromGitter> <Blacksmoke16> lol
<FromGitter> <Blacksmoke16> https://paste.ee/p/lShoJ
iwq has quit [Ping timeout: 246 seconds]
iwq has joined #crystal-lang