Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
A simple date validator for Rails. Should be compatible with all latest Rubies (>2.2, includes Ruby 3.0).
$ gem install date_validator
And I mean simple. In your model:
validates :expiration_date, date: true
or with some options, such as:
validates :expiration_date,
date: { after: Proc.new { Time.now },
before: Proc.new { Time.now + 1.year } }
# Using Proc.new prevents production cache issues
If you want to check the date against another attribute, you can pass it a Symbol instead of a block:
# Ensure the expiration date is after the packaging date
validates :expiration_date,
date: { after: :packaging_date }
or access attributes via the object being validated directly (the input to the Proc):
validates :due_date,
date: { after_or_equal_to: Proc.new { |obj| obj.created_at.to_date }
# The object being validated is available in the Proc
For now the available options you can use are :after
, :before
,
:after_or_equal_to
, :before_or_equal_to
and :equal_to
.
If you want to specify a custom message, you can do so in the options hash:
validates :start_date,
date: { after: Proc.new { Date.today }, message: 'must be after today' },
on: :create
Pretty much self-explanatory! :)
If you want to make sure an attribute is before/after another attribute, use:
validates :start_date, date: { before: :end_date }
If you want to allow an empty date, use:
validates :optional_date, date: { allow_blank: true }
Copyright (c) 2013 Codegram. See LICENSE for details.
FAQs
Unknown package
We found that date_validator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.