Skip to content

Commit

Permalink
[feat] add permit_empty to config file (#43)
Browse files Browse the repository at this point in the history
* [feat] add permit_empty to config file

* Update src/Concerns/UsesCipherSweet.php

---------

Co-authored-by: Rias <hey@rias.be>
  • Loading branch information
aryala7 and riasvdv committed Jul 11, 2023
1 parent 3317bb2 commit 6a1f2c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions config/ciphersweet.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,12 @@
],
// 'custom' => CustomKeyProviderFactory::class,
],
/**
* The provided code snippet checks whether the $permitEmpty property is set to false
* for a given field. If it is not set to false, it throws an EmptyFieldException indicating
* that the field is not defined in the row. This ensures that the code enforces the requirement for
* the field to have a value and alerts the user if it is empty or undefined.
* Supported: "true", "false"
*/
'permit_empty' => false
];
2 changes: 1 addition & 1 deletion src/Concerns/UsesCipherSweet.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function deleteBlindIndexes(): void

public function decryptRow(): void
{
$this->setRawAttributes(static::$cipherSweetEncryptedRow->decryptRow($this->getAttributes()), true);
$this->setRawAttributes(static::$cipherSweetEncryptedRow->setPermitEmpty(config('ciphersweet.permit_empty', false))->decryptRow($this->getAttributes()), true);
}

public function scopeWhereBlind(
Expand Down

0 comments on commit 6a1f2c4

Please sign in to comment.