Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Does it work with validator unique rule? If so should rules be unique:collection? #77

Copy link
Copy link
Closed
@bitinn

Description

@bitinn
Issue body actions

A simple rule appear to result in this problem:

1) MongoCategoryTest::testValidationUniqueId

ErrorException: Undefined index: result

/var/www/leaf/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Builder.php:151
/var/www/leaf/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1005
/var/www/leaf/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Builder.php:230
/var/www/leaf/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1311
/var/www/leaf/vendor/laravel/framework/src/Illuminate/Validation/DatabasePresenceVerifier.php:57
/var/www/leaf/vendor/laravel/framework/src/Illuminate/Validation/Validator.php:759
/var/www/leaf/vendor/laravel/framework/src/Illuminate/Validation/Validator.php:264
/var/www/leaf/vendor/laravel/framework/src/Illuminate/Validation/Validator.php:225
/var/www/leaf/vendor/laravel/framework/src/Illuminate/Validation/Validator.php:239
/var/www/leaf/app/models/BaseModelMongo.php:35

my validation method:

    /**
     * Take some data and validate again model rules
     *
     * @param   array    data for validation      
     * @return  boolean  result
     */
    public function validate($data)
    {
        // make a new validator object
        $v = Validator::make($data, $this->rules);

        // check for failure
        if ($v->fails())
        {
            // set errors and return error message
            $this->errors = $v->messages();
            return false;
        }

        // validation pass
        return true;
    }

rules:

    protected $rules = array(
        'id' => 'unique:collection|min:1',
        'slug' => 'unique:collection|min:1|max:64',
        'name' => 'min:1|max:256',
    );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.