Ticket #10 (new enhancement)

Opened 12 months ago

Add human-readable/useful stringification to Arrow::FormValidator

Reported by: deveiant Owned by: deveiant
Priority: high Milestone: Theres No Step Three
Component: FormValidator Version: 1.0
Severity: major Keywords: formvalidator to_s inspect stringify readable output
Cc:

Description

Currently FormValidator? stringifies to an empty string, and its #inspect returns something like this:

#<Arrow::FormValidator:0x3ceb8e8 @form={"evalstring"=>"txn.vargs"},
 @optional_fields=["evalstring"], @unknown_fields=[], 
@raw_form={"evalstring"=>"txn.vargs"}, @require_some_fields=[], @missing_fields=[],
 @untaint_fields=[], @required_fields=[], @profile={:descriptions=>{}, 
:constraints=>{"evalstring"=>/^[[:print:]]+$/}, :optional=>["evalstring"], 
:untaint_all_constraints=>true}, @filters_array=[], @invalid_fields={}, 
@untaint_all=true>

While this is useful on some level, I'd like to add a #to_s that rendered the object with a description that is easier to read and diagnose problems from.

For a validator which hasn't yet been combined with form data:

Form (unvalidated)
  1 required field/s:
   * name: /^[[:print:]]+$/
  4 optional field/s:
   * age: :integer
   * rank: one of: ['dungbeetle', 'private', 'corporal', 'sergeant']
   * eyecolor: one of: ['brown', 'green', 'blue', 'black', 'red']
   * state: :us_state

After combining with form data:

Form (validated+untainted)
  1 of 1 required fields
    * name: bloolark
  2 of 4 optional field/s:
    * age: 11
    * rank: 'Private'
  1 invalid field/s:
    * monkey_length: '113'
Note: See TracTickets for help on using tickets.