Socket
Book a DemoInstallSign in
Socket

shadow_form

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shadow_form

0.0.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

ShadowForm

Fat model with validation on all cases always causes problems in the future. So my solution is ShadowForm. Now you can have your original model without validation and use form when you need it.

Installation

Add this line to your application's Gemfile:

gem 'shadow_form'

And then execute:

$ bundle

Or install it yourself as:

$ gem install shadow_form

How it works

You have your active_record or active_model model:

class User
  include ActiveModel::Model
  attr_accessor :name, :email, :password
end

And for example register form

class UserRegistrationForm < ShadowForm::Core
  shadow_of User
  give_name 'RegisterForm` # optional
  validation do
    validates :email, presence: true
    validates :password, presence: true
  end
end

And now you have UserRegistrationForm like User + Validation

Contributing

  • Fork it ( https://github.com/[my-github-username]shadow_form/fork )
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create a new Pull Request

FAQs

Package last updated on 27 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.