validates_type:Rails的类型验证

时间:2021-05-08 00:10:21
【文件属性】:
文件名称:validates_type:Rails的类型验证
文件大小:16KB
文件格式:ZIP
更新时间:2021-05-08 00:10:21
hacktoberfest Ruby validates_type Rails类型验证 目的 大多数Rails应用程序将具有由其ORM连接适配器强制的类型(例如pg gem或mysql2 )。 但是,这仅对具有定义良好的架构的应用程序有用。 如果您的应用程序具有无法再修改的旧式存储层或许多store_accessor列,则此解决方案是确保数据健壮的良好中间立场。 这还可以防止您的数据被ActiveRecord适配器强制转换为您不希望的值。 用法 使用ActiveRecord class Foo < ActiveRecord :: Base # validate that attribute :bar is a String validates_type :bar , :string # validate that attribute :baz is an Integer with a custom error
【文件预览】:
validates_type-master
----.gitignore(27B)
----validates_type.gemspec(1KB)
----.travis.yml(91B)
----errors()
--------unsupported_type.rb(136B)
----LICENSE.txt(1KB)
----spec()
--------arguments_spec.rb(2KB)
--------active_model()
--------activerecord()
--------active_record_helper.rb(871B)
--------spec_helper.rb(150B)
--------active_model_helper.rb(2KB)
----README.md(3KB)
----lib()
--------validates_type.rb(6KB)
--------arguments.rb(1KB)
----locale()
--------en.yml(79B)
----version.rb(111B)
----Gemfile(39B)
----Gemfile.lock(1KB)

网友评论