News for hackers. Stuff that matters.
Re:Parsix: Parse Don't Validate by throwawayboise on Saturday May 15, 2021 @02:29PM (#27167662)
I do as much of this as I can with database constraints. Foreign key constraints, or check constraints, or even triggers if necessary (though I do try to avoid them).

Databases tend to outlive application code, or may be fronted by different applications (internal vs external for example). Keeping the constraints with the data is the best way to ensure that your data remains consistent within itself.

Re:Parsix: Parse Don't Validate by jhardy54 on Saturday May 15, 2021 @02:34PM (#27167708)
I do this too, but I’m always frustrated by the mismatch between database constraints and application constraints. For example, when using Django you can declare a field as varchar(32) but that constraint isn’t checked until you actually insert the row into the database. I suppose maybe that’s not a problem in languages with more mature type safety ecosystems?
Re:Parsix: Parse Don't Validate by Iazel on Saturday May 15, 2021 @02:43PM (#27167795)
Yeah, I've also worked with weak type systems in the past too (PHP, Ruby, JS), so I can definitely share the pain! I learned the hard way how much easier it is to build complex systems when you have a compiler helping you ;)
Re:Parsix: Parse Don't Validate by teddyh on Sunday May 16, 2021 @02:37AM (#27171690)
Please do not confuse strong/weak typing with dynamic/static typing. Many dynamically typed languages are also weakly typed, but some dynamic langugages, like Python, are strongly typed.
Re:Parsix: Parse Don't Validate by Iazel on Sunday May 16, 2021 @06:31AM (#27172664)
Fair point, thanks for calling it out. I should have said "statically checked, strongly typed languages"
Re:Parsix: Parse Don't Validate by jhardy54 on Saturday May 15, 2021 @03:29PM (#27168140)
What are you building with now? Rust/Go/something snazzy?
Re:Parsix: Parse Don't Validate by Iazel on Sunday May 16, 2021 @06:33AM (#27172672)
I'm using Kotlin and still PHP in some legacy part at work, but whenever I can in my free-time I use Haskell, Elm and read about FP concepts. What about you? :)
Re:Parsix: Parse Don't Validate by lolinder on Sunday May 16, 2021 @12:00AM (#27171102)
Judging from the library they wrote, I'd guess Kotlin.
Re:Parsix: Parse Don't Validate by Iazel on Saturday May 15, 2021 @02:41PM (#27167774)
I see, this is also an interesting approach and definitely have its usages. Thinking about it, though, it has its own limitations when it comes to scalability and business requirements naturally out from the database box, eg: how would you ensure an S3 file reference is actually valid and it does exist?
Re:Parsix: Parse Don't Validate by mixedCase on Sunday May 16, 2021 @02:38AM (#27171691)
You can't, since the file can be deleted from under you after verification anyway. But you can treat it as an "S3FileReference" or something arbitrarily generic like "RemoteFile" and have associated procedures/methods for verifying the properties you want at any point without confusing it with "just a string"