Skip to content

Commit

Permalink
Run Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyzerner committed Aug 24, 2023
1 parent 5ffc3fb commit b2bca3f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 1 addition & 2 deletions docs/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ Str::make('name')
You can restrict the string to a set of possible values using the `enum` method.

```php
Str::make('status')
->enum(['to do', 'doing', 'done']);
Str::make('status')->enum(['to do', 'doing', 'done']);
```

#### `pattern`
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/Field/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(string $name)
}

if ($this->enum !== null && !in_array($value, $this->enum, true)) {
$enum = array_map(fn ($value) => '"' . $value . '"', $this->enum);
$enum = array_map(fn($value) => '"' . $value . '"', $this->enum);
$fail(sprintf('must be one of %s', implode(', ', $enum)));
}

Expand Down
12 changes: 10 additions & 2 deletions tests/feature/StrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ public function test_invalid_enum()
new MockResource(
'users',
endpoints: [Create::make()],
fields: [Str::make('type')->writable()->enum(['A', 'B'])],
fields: [
Str::make('type')
->writable()
->enum(['A', 'B']),
],
),
);

Expand All @@ -83,7 +87,11 @@ public function test_valid_enum()
new MockResource(
'users',
endpoints: [Create::make()],
fields: [Str::make('type')->writable()->enum(['A', 'B'])],
fields: [
Str::make('type')
->writable()
->enum(['A', 'B']),
],
),
);

Expand Down

0 comments on commit b2bca3f

Please sign in to comment.