Comments (15)
I'm taking it !
from actor.
That makes a lot of sense! I’d be happy to merge a PR for that 🙏🏻
from actor.
@williampollet Would you be willing to try a patch for this feature using the array: true
syntax? 🙏🏻
from actor.
Actually, since now the array syntax for types is used as an "or":
input :age, type: [Integer, Float]
I think it would make more sense to just keep the plural and not have an array:
input :order, type: Order
inputs :orders, type: Order
But perhaps better than the plural which can be a bit too discreet, having it as a new array: true
option could make it much more explicit:
input :order, type: Order
input :orders, type: Order, array: true
from actor.
One import disadvantage of array: true
it that it won't support type: [T, [T]]
input constraints usecase.
In gerenal [T]
seems to be more generic ADT-like approach
from actor.
Good point. I think I’d still like the constraints here to be as light as possible and not try to handle all possible types.
One way we could accept more types would be to lean on another constraints/validation gem.
from actor.
One way we could accept more types would be to lean on another constraints/validation gem.
Do you have examples of such gems in mind?
from actor.
I was thinking of dry-validations, or ActiveRecord validations (perhaps with type_validator). But there may be others.
from actor.
I think we could come up with some sort of global configuration option that will switch from our (default) type validation backend to gem-provided backend
dry-rb is more popular, should I try to implement a PoC for this? @sunny
from actor.
I think it would make sense to use dry-validations
but I wouldn’t want the gem as a dependency for people who are fine with the simpler current syntax.
I don’t know what the best course of action for that would be. Maybe this means that the glue code between actor
and dry-validations
lives in a different gem?
from actor.
Yeah, I think we only need to expose some interface so that other gems might use it to provide 3rd-party-gem-backed validation. Also some sort of a global configuration option to select implementation
from actor.
Yeah, makes sense. We could have for example:
config.validations = :default
,config.validations = :rails
if you include theservice_actor-rails
gem,config.validations = :dry_validation
with a newservice_actor-dry-validation
gem.
To allow that, perhaps the current validations could use more generic before
, after
& around
hooks to avoid having to monkey-patch.
from actor.
To allow that, perhaps the current validations could use more generic before, after & around hooks to avoid having to monkey-patch.
Could you elaborate on that? Seems like I'm missing something here
from actor.
Apart from dry-validations, can we add array: true
syntax right now? I'm interested in this feature
from actor.
To allow that, perhaps the current validations could use more generic before, after & around hooks to avoid having to monkey-patch.
I was thinking of a way of “hooking” into actor from outside gems. Using for example before_call :validate_type
that could be an interface that can allow outside gems the to add some validation behavior (or any kind of other behavior) and perhaps remove some other behavior (skip_before_call :validate_type
). (See also #111).
Not sure this would be the best way to do that, just some thoughts.
Apart from dry-validations, can we add
array: true
syntax right now? I'm interested in this feature
Sure!
Note that you can do a similar check today with:
input :names,
type: Array,
must: {
be_strings: -> array { array.all?(String) }
}
from actor.
Related Issues (20)
- Feature request: use other input values in default HOT 4
- alias_input is documented but unavailable HOT 1
- What about improving the README about testing? HOT 1
- Get "TypeError: exception class/object expected" error when update from 3.1.3 to 3.6 HOT 2
- Question / feature request: hooks around call? HOT 6
- Missing note on stubbing ServiceActor::Result HOT 4
- Can't set an hash as a default value for an input HOT 1
- Keep Zeitwerk as a development dependency only HOT 2
- Consider removing `OpenStruct` usage HOT 2
- Consider dropping support for unmaintained Ruby releases HOT 1
- Misleading `ServiceActor::ArgumentError` message under specific circumstances HOT 8
- Make Actor result + pattern matching more pleasant HOT 1
- Actor's output names collision with `Object`'s instance methods HOT 2
- Using `Kernel.tap` and `Kernel.then` via `ServiceActor::Result` receiver HOT 1
- Is `DefaultCheck` obsolete? HOT 4
- Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. HOT 29
- Release notes for 3.8.0 HOT 8
- [Proposal] Default outputs via `output_of` actor class method HOT 3
- Breaking changes on ServiceActor::Result `failure?` after dropping `ostruct` ??? HOT 5
- Repeated `play` execution on 3.9.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from actor.