Comments (5)
Hi @Hirurg103, I'm not associated with the simple_command project, but I gave this a look.
I am not seeing this problem; I tried looking through the code and it appears to act the way you expect it to work. I wrote an rspec test to verify this behaviour, and it works as expected.
I created a new Rails, wrote a Command that recreates the errors in your example, and it still behaved as expected.
Have you found this issue to be resolved? or have I missed something while looking into it?
from simple_command.
I have missed something, not including ActiveModel::Validations
does produce the errors object you are referencing.
I wrote a small gist that replicates this problem:
# app/commands/authenticate_user.rb
class AuthenticateUser
prepend SimpleCommand
# include ActiveModel::Validations
def initialize(email, password)
@email = email
@password = password
end
def call
errors.add(:email, "is invalid")
errors.add(:email, "is from a blocked domain")
errors.add(:password, "is too common")
nil
end
end
# app/controllers/authenticate_controller.rb
class AuthenticateController < ApplicationController
def create
load_users = AuthenticateUser.(params[:email], params[:password])
if load_users.success?
render json: load_users.result
else
render json: { errors: load_users.errors }
end
end
end
Output:
"errors" => {"email"=>"is from a blocked domain", "password"=>"is too common"}
from simple_command.
Hi @bmorrall , yes, this error is reproducible with pure SimpleCommand
(without including ActiveModel::Validations
)
from simple_command.
This PR should fix that #25
from simple_command.
I had the same issue, thanks for reporting and for the PR, hope they will merge it soon and release a new version. The bump from 0.0.9 would be a MAJOR release since we had break changes and not a minor how it was.
from simple_command.
Related Issues (15)
- uninitialized constant HOT 1
- Suggestion: Implement full_messages method for Errors HOT 2
- undefined method `full_messages` for SimpleCommand::Errors HOT 2
- How to modify default token expiration time HOT 1
- Release the gem onto https://rubygems.org HOT 2
- version 0.1.0 brakes add_multiple_errors HOT 1
- Using Ruby 3 style keyword arguments raises warning in Ruby 2.7 HOT 1
- Cut a new release now that Ruby 3.0 is out HOT 6
- Failing Build? HOT 1
- Add new assistance categories HOT 1
- How mock with rspec with prepended SimpleCommand HOT 1
- How to export command errors in ams ErrorSerializer? HOT 4
- how to test with rspec? HOT 2
- LoadError: Unable to autoload constant [command] HOT 4
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 simple_command.