makeRegexValidator example

/** * @return PropertyDefinitions */
    private static function getPropertyDefinitions(): array
    {
        $properties = [
            [
                'name' => 'name',
                'prompt' => 'Please enter a name for your app',
                'description' => 'The name of your app. Used for the folder structure.',
                'default' => 'MyExampleApp',
                'validator' => self::makeRegexValidator(
                    '/^[A-Za-z]\w{3,}$/',
                    'The app name is too short (min 4 characters), contains invalid characters'
                ),
                'normaliser' => fn (string $name): string => u($name)->replace('_', ' ')->camel()->title()->toString(),
            ],
            [
                'name' => 'label',
                'prompt' => 'Please enter a label for your app',
                'description' => 'The label for your app.',
                'default' => 'My Example App',
                'validator' => self::makeRegexValidator(
                    
Home | Imprint | This part of the site doesn't use cookies.