3 namespace OpenEMR\Validators
;
5 use Particle\Validator\Validator
;
8 * Supports Insurance Company Record Validation.
11 * @link http://www.open-emr.org
12 * @author Vishnu Yarmaneni <vardhanvishnu@gmail.com>
13 * @copyright Copyright (c) 2021 Vishnu Yarmaneni <vardhanvishnu@gmail.com>
14 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 class InsuranceCompanyValidator
extends BaseValidator
19 * Configures validations for the Insurance Company DB Insert and Update use-case.
20 * The update use-case is comprised of the same fields as the insert use-case.
21 * The update use-case differs from the insert use-case in that fields other than uuid are not required.
23 protected function configureValidator()
25 parent
::configureValidator();
28 $this->validator
->context(
29 self
::DATABASE_INSERT_CONTEXT
,
30 function (Validator
$context) {
31 $context->required('name')->lengthBetween(2, 255);
32 $context->optional('attn')->lengthBetween(2, 255);
33 $context->optional('cms_id')->lengthBetween(2, 15);
34 $context->optional('alt_cms_id')->lengthBetween(2, 15);
35 $context->optional('ins_type_code')->numeric();
36 $context->optional('x12_receiver_id')->lengthBetween(2, 25);
37 $context->optional('x12_default_partner_id')->numeric();
41 // update validations copied from insert
42 $this->validator
->context(
43 self
::DATABASE_UPDATE_CONTEXT
,
44 function (Validator
$context) {
45 $context->copyContext(
46 self
::DATABASE_INSERT_CONTEXT
,
48 foreach ($rules as $key => $chain) {
49 $chain->required(false);
53 // additional uuid validation
54 $context->required("uuid", "Insurance UUID")->callback(function ($value) {
55 return $this->validateId("uuid", "insurance_companies", $value, true);