Validate title field on page creation

I want to avoid leading numbers in the title field of a subpage,
so I created a custom validator:

Plugin:

v::$validators['denyLeadingNum'] = function($value) {
  return preg_match('/^\d+/', $value) < 1 ?? false;
};

Blueprint:

    title:
        label: Titel
        type:  text
        validate: denyLeadingNum

It works fine, as long as I edit the title of a page,
but when I create a new page from a parent page, it’s no problem
to enter leading numbers. The page will be created anyway.
Is there a way to validate the title when creating a new page?
Thank You!

No, there is no standard way of validating input when the user enters the title.

I see two options:

  1. use a panel.page.create hook that automatically removes leading numbers from the title
  2. hijack the add form and create a custom form with field validation

Ok, I’ll give the panel.page.create hook a go.
Thanks, Sonja, Your help is as always much appreciated! :upside_down_face: