Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

globalize-validations

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

globalize-validations

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
3
Created
Source

Code Climate CI

Globalize-Validations

Globalize Validations validates your translated attributes for each given locales. The errors are added to the globalize attributes accessor names (example title_en).

globalize-validations is compatible with Rails 5.2, Rails 6.x and Rails 7.0.x.

Documentation

API documentation is available at rdoc.info.

Installation

Add this line to your application's Gemfile:

gem 'globalize-validations'

And then execute:

$ bundle

Usage

Default

class Page < ActiveRecord::Base
  translates :title, :body
  globalize_accessors locales: [:en, :es, :fr, :pl], attributes: [:title]
  globalize_validations # Will use Model.globalize_locales by default

  # Add all your validations before
  validate :validates_globalized_attributes
end

With custom locales

class Page < ActiveRecord::Base
  translates :title, :body
  globalize_accessors locales: [:en, :es, :fr, :pl], attributes: [:title]
  globalize_validations locales: [:en, :es] # Validates only `:en` and `:es` locales

  # Add all your validations before
  validate :validates_globalized_attributes
end

With custom locales as Proc

class Page < ActiveRecord::Base
  translates :title, :body
  globalize_accessors locales: [:en, :es, :fr, :pl], attributes: [:title]
  globalize_validations locales: Proc.new { |page| page.available_locales }

  # Add all your validations before
  validate :validates_globalized_attributes
end

Licence

Copyright (c) 2014 BookingSync released under the MIT license

FAQs

Package last updated on 06 Sep 2021

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc