Comments (4)
Hey @koki-sato what would be a use-case for such behavior?
Is it just for instantiation and before persisting?
from array_enum.
Is it just for instantiation and before persisting?
Yes!
I expect the following behavior.
class User < ActiveRecord::Base
extend ArrayEnum
array_enum favourite_colors: {"red" => 1, "blue" => 2, "green" => 3}
validates :favourite_colors, subset: { in: favourite_colors.keys }
end
user = User.new(favourite_colors: [""]) # Do not raise ArgumentError!
user.save # => false
user.errors.messages[:favourite_colors] # Display inclusion validation error message
For example, when the following data is HTTP POSTed in an HTML Form
user[favourite_colors][]:
Rails Parameters look like this:
Parameters: { "user" => { "favourite_colors" => [""] } }
from array_enum.
@koki-sato I'll have a look into it, tho can't give a timeline right now. But if you already have some idea on how it'll work, feel free to create a PR and I'll review it.
from array_enum.
Related Issues (3)
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 array_enum.