auraphp / Aura.Filter

Validate and sanitize arrays and objects.
MIT License
159 stars 33 forks source link

Sanitize is causing validation error #123

Closed designermonkey closed 8 years ago

designermonkey commented 8 years ago

Maybe I've missed something, and hopefully this can be closed pretty quickly.

        $f->sanitize('member-url')->toBlankOr('callback', function ($subject, $field) {
            if (strlen($subject->$field) > 0 && strpos($subject->$field, 'http://') !== false) {
                $subject->$field = 'http://'.$subject->$field;
            }
        });
        $f->validate('member-url')->isBlankOr('url')->asSoftRule('Your website should be a valid url.');

Basically, if the field has a value, I want to ensure it starts with http, but this combination always gives me:

member-url should have sanitized to callback(*Closure*)

Can anyone triage what's wrong here?

pmjones commented 8 years ago

Try return true to indicate the sanitizing worked (i.e., inside the closure).

harikt commented 8 years ago

also @designermonkey if you have questions / doubts I wished if you could write to google groups. There will be other people also willing to help.

Thank you for your consideration.

designermonkey commented 8 years ago

Ok thanks @pmjones