Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion formwork/fields/color.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
return [
'methods' => [
'validate' => function (Field $field, $value): string {
if (!Constraint::matchesRegex($value, '/^#[0-9A-Fa-f]{6}$/')) {
if (!Constraint::matchesRegex($value, '#[0-9A-Fa-f]{6}')) {
throw new ValidationException(sprintf('Invalid value for field "%s" of type "%s"', $field->name(), $field->type()));
}

Expand Down
2 changes: 1 addition & 1 deletion formwork/schemes/config/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fields:
label: '{{panel.options.system.files.allowedExtensions}}'
icon: file-exclamation
placeholder: '{{panel.options.system.files.allowedExtensions.noExtensions}}'
pattern: '^\.[a-zA-Z0-9]+$'
pattern: '\.[a-zA-Z0-9]+'
options@: mimeTypes.getExtensionTypes()

cache.enabled:
Expand Down
5 changes: 4 additions & 1 deletion formwork/src/Utils/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ public static function isEqualTo(mixed $value, mixed $comparison, bool $strict =
/**
* Return whether a value matches the specified regex pattern
*/
public static function matchesRegex(string $value, string $regex): bool
public static function matchesRegex(string $value, string $regex, bool $entireMatch = true): bool
{
if ($entireMatch) {
$regex = '^(?:' . trim($regex, '^$/') . ')$';
}
return (bool) @preg_match(Str::wrap($regex, '/'), $value);
}

Expand Down
2 changes: 1 addition & 1 deletion panel/modals/newPage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fields:
label: '{{page.slug}}'
suggestion: '{{page.slug.suggestion}}'
required: true
pattern: '^[a-z0-9\-]+$'
pattern: '[a-z0-9\-]+'
source: title
root: parent

Expand Down
2 changes: 1 addition & 1 deletion site/schemes/config/site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fields:
label: '{{panel.site.languages.availableLanguages}}'
icon: translate
placeholder: '{{panel.site.languages.availableLanguages.noLanguages}}'
pattern: '^[a-z]{2,3}$'
pattern: '[a-z]{2,3}'
translate: [label, placeholder]
options@: languages.names

Expand Down