GreaterThanOrEqual example

return new NoContentResponse();
    }

    private function validate(DataBag $data, Context $context): void
    {
        $definition = new DataValidationDefinition('product.create_rating');

        $definition->add('name', new NotBlank());
        $definition->add('title', new NotBlank()new Length(['min' => 5]));
        $definition->add('content', new NotBlank()new Length(['min' => 40]));

        $definition->add('points', new GreaterThanOrEqual(1)new LessThanOrEqual(5));

        if ($data->get('id')) {
            $criteria = new Criteria();
            $criteria->addFilter(new EqualsFilter('customerId', $data->get('customerId')));
            $criteria->addFilter(new EqualsFilter('id', $data->get('id')));

            $definition->add('id', new EntityExists([
                'entity' => 'product_review',
                'context' => $context,
                'criteria' => $criteria,
            ]));
        }
return new CalculatedPrice($shippingCosts['unitPrice']$shippingCosts['totalPrice']new CalculatedTaxCollection()new TaxRuleCollection());
    }

    private function validateShippingCostsParameters(Request $request): void
    {
        if (!$request->request->has('shippingCosts')) {
            throw ApiException::shippingCostsParameterIsMissing();
        }

        $validation = new DataValidationDefinition('shipping-cost');
        $validation->add('unitPrice', new NotBlank()new Type('numeric')new GreaterThanOrEqual(['value' => 0]));
        $validation->add('totalPrice', new NotBlank()new Type('numeric')new GreaterThanOrEqual(['value' => 0]));
        $this->validator->validate($request->request->all('shippingCosts')$validation);
    }
}


    public function isLengthLessThanOrEqual(int $maxLength): self
    {
        $this->addConstraint(new Length(['max' => $maxLength]));

        return $this;
    }

    public function isGreaterThanOrEqual(int $value): self
    {
        $this->addConstraint(new GreaterThanOrEqual($value));

        return $this;
    }

    public function isLessThanOrEqual(int $value): self
    {
        $this->addConstraint(new LessThanOrEqual($value));

        return $this;
    }

    
private function addConstraintsSalesChannelContext(DataValidationDefinition $definition, SalesChannelContext $context): void
    {
        $definition->add('salutationId', new EntityExists(['entity' => $this->salutationDefinition->getEntityName(), 'context' => $context->getContext()]))
            ->add('firstName', new NotBlank())
            ->add('lastName', new NotBlank())
            ->add('accountType', new Choice($this->accountTypes));
    }

    private function addConstraintsBirthday(DataValidationDefinition $definition): void
    {
        $definition
            ->add('birthdayDay', new GreaterThanOrEqual(['value' => 1])new LessThanOrEqual(['value' => 31]))
            ->add('birthdayMonth', new GreaterThanOrEqual(['value' => 1])new LessThanOrEqual(['value' => 12]))
            ->add('birthdayYear', new GreaterThanOrEqual(['value' => 1900])new LessThanOrEqual(['value' => date('Y')]));
    }
}


        $definition
            ->add('salutationId', new EntityExists(['entity' => $this->salutationDefinition->getEntityName(), 'context' => $frameworkContext]))
            ->add('firstName', new NotBlank())
            ->add('lastName', new NotBlank())
            ->add('accountType', new Choice($this->accountTypes));

        if ($this->systemConfigService->get('core.loginRegistration.showBirthdayField', $salesChannelId)
            && $this->systemConfigService->get('core.loginRegistration.birthdayFieldRequired', $salesChannelId)) {
            $definition
                ->add('birthdayDay', new GreaterThanOrEqual(['value' => 1])new LessThanOrEqual(['value' => 31]))
                ->add('birthdayMonth', new GreaterThanOrEqual(['value' => 1])new LessThanOrEqual(['value' => 12]))
                ->add('birthdayYear', new GreaterThanOrEqual(['value' => 1900])new LessThanOrEqual(['value' => date('Y')]));
        }
    }
}
Home | Imprint | This part of the site doesn't use cookies.