Project

preform

0.0
No commit activity in last 3 years
No release in over 3 years
Preform
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0
 Project Readme

Preform

A small library for validating user input. It includes a mixin, Validatable, and two opinionated classes that include it: Form, and Field.

Usage

Installation

gem install preform

API

Validatable

validate: Template command method that needs to be implemented. Runs to determine errors.

valid?: Query to see if any errors exist.

errors: Returns the errors hash.

merge_errors!: Given another validatable, merges errors into self's errors.

assert: Tests a value to see if an error should be added or not. Always returns a boolean so asserts can be nested.

Form

after_initialize: Override to perform custom initialization behavior.

params: Raw params given to the form.

attributes: Hook that allows you to transform params for use in your application. By default returns raw params.

Field

after_initialize: Override to perform custom initialization behavior.

key: Reader for the form key, used when merging errors into a form.

value: Raw value to validate.