++ed by:

1 non-PAUSE user.

Konstantin S. Uvarin

NAME

MVC::Neaf::X::Form::Data - Form validation result object.

CAUTION

This module should be moved into a separate distribution or (ideally) merged with an existing module with similar functionality.

Possible candidates include Validator::LIVR, Data::FormValidator, Data::CGIForm, and more.

DESCRIPTION

See MVC::Neaf::X::Form. This class is not expected to be created and used directly.

METHODS

new( %options )

%options may include:

  • data - data that passed validation

  • error - fields that failed validation with correspondent error messages.

  • raw - data as it was before validation. This should in theory match data + error, but isn't check in any way.

fields()

Return fields currently in either data or raw hashes.

is_valid()

Returns true if data passed validation, false otherwise.

data

Returns data that passed validation as hashref. This MAY be incomplete, check is_valid() first.

data( "key" )

Get specific data item.

data( key => $newvalue )

Set specific data item.

error

Returns errors that occurred during validation.

error( "key" )

Get specific error item.

error( key => $newvalue )

Set specific error item. This may be used to invalidate a value after additional checks, and will also reset is_valid.

raw

Returns raw input values as hashref. Only keys subject to validation will be retained.

This may be useful for sending the data back for resubmission.

raw( "key" )

Get specific raw item.

raw( key => $newvalue )

Set specific raw item.

as_url( %override )

Return the cleansed form data as one url-encoded line. The keys are sorted, and empty/undef values are discarded.

Arrays are NOT supported (yet). This may change in the future.

sign( %options )

Sign data with a key. Empty values are discarded. The same data set with the same key is guaranteed to produce the same signature, at least in the same module version.

Options may include:

  • key (required) - the encryption key. If unsure, run pwgen(1) and hardcode something from its output.

  • crypt = CODE($data, $key) - use that function for encryption. The default is simple sha1-based hash. You may need a more secure alternative.

  • override = %hash - override these values.

  • discard = @list - discard these values. This takes over override. May be needed e.g. to check if the form matches signature that comes with the form itself.

LICENSE AND COPYRIGHT

This module is part of the MVC::Neaf suite.

Copyright 2016-2017 Konstantin S. Uvarin.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.