New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

boof-not-naughty

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boof-not-naughty

  • 0.6.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= NotNaughty - The Validation Framework

NotNaughty extends your ruby Project with a highly custumizable validation API.

== Features

Easy to adapt:

require 'rubygems' require 'not_naughty'

Person = Struct.new(:name) do extend NotNaughty validates(:name) { presence and length :minimum => 4 } end

Person.new('Horst').valid? # => true Person.new('Foo').valid? # => false

Easy to extent:

class ExampleValidation < NotNaughty::Validation def initialize(options, attributes) msg = options[:message] || '#{"%s".humanize} is not an example.'

   super options, attributes do |record, attribute, value|
     record.errors.add(attribute, msg) unless value.is_a? Example
   end
 end

end

Person.instance_eval do validates_example_of :example_attribute end

Handle SQL error gracefully:

Person.instance_eval do validator.error_handler.handle(SQLError) { |err| '...' } end

Syntactical Sugar with Builder methods:

validates(:username, :password, :if => :new?) {length :minimum => 6} validates(:password, :allow_blank => 1) {confirmation and complexity :high}

Beautiful error messages:

validates_presence_of :red_shoes, :message => '#{"%s".humanize} are not here.' # => Red shoes are not here.

Conditional Validations:

validates(:if => :necessary?) {...} validates(:unless => proc {|obj| obj.vip?}) { '...' }

== Copying

:include: COPYING

FAQs

Package last updated on 11 Aug 2014

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