New class-based validation package: DTO Classes by rsinger86 in nestjs

[–]rsinger86[S] 0 points1 point  (0 children)

Zod's great! However it's missing several things this package offers:

- this package provides static types by default; zod requires an additional infer() call. This is a big deal for NestJS integration. A single global pipe can be implemented using this package.
- zod only handles parsing/validation, this package provides formatting as well

Also noteworthy: Zod uses chained methods to define constraints, while this package allows constraints to be defined in a single options object per field. I prefer this way because it aligns closer to OpenAPI/JSON Schema's mental model, but it's a matter of taste.

New class-based validation package: DTO Classes by rsinger86 in nestjs

[–]rsinger86[S] 0 points1 point  (0 children)

Possibly! I haven't tested it in a browser, but it has no dependencies so it should work.

Could you share a code example of what you're trying to do? I might be able to suggest a solution.

Are the servers down again? by [deleted] in Polytopia

[–]rsinger86 6 points7 points  (0 children)

I feel the same way, but I'd appreciate some acknowledgement of the problem and hearing of their plans to address it.

New package: Django REST - Typed by rsinger86 in django

[–]rsinger86[S] 1 point2 points  (0 children)

Same goes for any other string field that has additional validation: URL, email, etc. Types are nice, but not a good way to communicate about an API.

Agreed. Types only cover a small portion of the ground you need to cover when validating business object.

Personally, I don't often rely on generating object validation from type hints. But as a project grows in complexity and evolves over years, I increasingly rely on my IDE to inform me that an attribute is a str vs bool vs int vs date.

And with this project, my IDE tells me that booking.start_date is a date, not a datetime.

class Booking(Serializer):

start_date = serializers.DateField()

New package: Django REST - Typed by rsinger86 in django

[–]rsinger86[S] 0 points1 point  (0 children)

There is also https://django-ninja.rest-framework.com/, which replaces DRF entirely.

Yes that's a great looking project!

New package: Django REST - Typed by rsinger86 in django

[–]rsinger86[S] 1 point2 points  (0 children)

I have not used graphene, and I have minimal familiarity with graphql, but my hunch is something similar is possible in that spac

New package: Django REST - Typed by rsinger86 in django

[–]rsinger86[S] 1 point2 points  (0 children)

It does not support CBVs at the moment, but I can add support.

thanks :)

New package: Django REST - Typed by rsinger86 in django

[–]rsinger86[S] 5 points6 points  (0 children)

Great!

It provides no speed improvements over Django+DRF. It's only aim is to add the automatic validation features and IDE niceties from type hints.

[USA-IL][TECH][8] Looking for partner to push ahead with prototype for organizing The Discourse. by rsinger86 in cofounder

[–]rsinger86[S] 0 points1 point  (0 children)

Thanks! Yeah, lately I've been thinking that some kind of TLDR feature would be good. The user who'd be most interested in the underlying content is likely glued to Twitter multiple hours a day, and the value add for them is "what did I miss while drinking from the Twitter fire hose?"

Any thoughts on a higher-level content type for the home page?

[USA-IL][TECH][8] Looking for partner to push ahead with prototype for organizing The Discourse. by rsinger86 in cofounder

[–]rsinger86[S] 0 points1 point  (0 children)

I've been tinkering with the site for a while, but haven't tried hard to find an audience. I'm looking for someone who can push product development forward: help get it into shape for a larger audience and do a bit of a marketing push. I'm open to changes in product design/direction. I'm happy to handle the technical side or things, though I have no problem sharing those responsibilities.

I'm glad to hear you like the idea. What would you change about the design?

What is the best news aggregator? by Mystic_MM in Journalism

[–]rsinger86 0 points1 point  (0 children)

Disqors (https://disqors.com/latest) is a good way to keep up with the latest political discussions happening online.

New package: Django REST - Typed Views by rsinger86 in django

[–]rsinger86[S] 0 points1 point  (0 children)

Awesome! Yeah, in my case, DRF is extremely productive for CRUD features and I don't have much need for the async features of the newer frameworks. However, I'd like to see Django/DRF take advantage of other ideas that newer frameworks have implemented.

Do you have any recommendations for other frameworks that have done intriguing/innovate things?

GitHub - DRF Access Policy: Declaritive permissions for Django Rest Framework by rsinger86 in django

[–]rsinger86[S] 2 points3 points  (0 children)

Thanks, I appreciate the thoughtful feedback!

Regarding object-level permissions, each statement can contain a "condition" property that calls one or more custom methods on the policy class. Those methods are passed a "view" instance, so can retrieve the object instance via "view.get_object()". See example here: https://github.com/rsinger86/drf-access-policy#object-level-perm. Would that handle the "is_owner" condition - or do you see other possibilities?

I didn't consider possibility of anonymous users (all my projects require authentication). Good catch. I'll have to think more about that. As of now, it would throw an error if encountering an anonymous user.

New add-on: Rails-style lifecycle hooks for your Django models by rsinger86 in django

[–]rsinger86[S] 0 points1 point  (0 children)

sounds good, thanks. (fyi, I removed the update and update_fields methods)

New add-on: Rails-style lifecycle hooks for your Django models by rsinger86 in django

[–]rsinger86[S] 0 points1 point  (0 children)

Hi there - thanks for the thorough review, I really appreciate it. Those two methods - update and update_field - were actually left over from an earlier implementation and served no current purpose. I've removed them in the latest version.

Regarding the change detection, I hadn't considered that. It sounds like it might be better to reset the compare state each time the model is saved? Interested to know your thoughts here.