Naoto Ishikawa > MongoDBx-Tiny-0.03 > MongoDBx::Tiny::Validator

Download:
MongoDBx-Tiny-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

MongoDBx::Tiny::Validator - validation on insert and update.

SUBROUTINES/METHODS ^

new

  $validator = MongoDBx::Tiny::Validator->new(
        $collection_name,
        $document,
        $tiny,
  );

document, collection_name, tiny

  # alias
  $document = $validator->document;
  $collection_name = $validator->collection_name;
  $tiny = $validator->tiny;

has_error

  $validator->has_error && die;

set_error

  $validator->set_error(
      $name => [
        'error-code','message',
      ]
  );

errors

  # erros: [{ field => 'field1', code => 'errorcode', message => 'message1' },,,]
  @erros         = $validator->erros; 
  
  @fields        = $validator->errors('field');
  @error_code    = $validator->errors('code');
  @error_message = $validator->errors('message');

check

  # no_validate: bool
  # state: [insert,update]
  $validator->check($opt); 

AUTHOR ^

Naoto ISHIKAWA, <toona at seesaa.co.jp>

LICENSE AND COPYRIGHT ^

Copyright 2013 Naoto ISHIKAWA.

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.

syntax highlighting: