1. Go to this page and download the library: Download limoncello-php/validation library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
class Rules extends \Limoncello\Validation\Rules
{
public static function sku(): RuleInterface
{
return static::stringToInt(new IsSkuRule());
}
public static function amount(int $max): RuleInterface
{
return static::stringToInt(static::between(1, $max));
}
public static function deliveryDate(): RuleInterface
{
return static::stringToDateTime(DateTime::ISO8601, new IsDeliveryDateRule());
}
public static function email(): RuleInterface
{
return static::isString(
static::filter(FILTER_VALIDATE_EMAIL, null, Errors::IS_EMAIL, static::stringLengthMax(255))
);
}
public static function address1(): RuleInterface
{
return static::isString(static::stringLengthBetween(1, 255));
}
public static function address2(): RuleInterface
{
return static::nullable(static::isString(static::stringLengthMax(255)));
}
public static function areTermsAccepted(): RuleInterface
{
return static::stringToBool(static::equals(true));
}
}