RainLab\Pages\Classes\Page::beforeValidate PHP Method

beforeValidate() public method

Throws a ValidationException in case of an error.
public beforeValidate ( )
    public function beforeValidate()
    {
        $pages = Page::listInTheme($this->theme, true);
        Validator::extend('uniqueUrl', function ($attribute, $value, $parameters) use($pages) {
            $value = trim(strtolower($value));
            foreach ($pages as $existingPage) {
                if ($existingPage->getBaseFileName() !== $this->getBaseFileName() && strtolower($existingPage->getViewBag()->property('url')) == $value) {
                    return false;
                }
            }
            return true;
        });
    }