Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Validation extends Fuel\Core\Validation{
- public static function _validation_unique($val, $options)
- {
- list($table, $field) = explode('.', $options);
- $result = DB::select(strtolower($field))
- ->where($field, '=', Str::lower($val))
- ->from($table)->execute('default');
- Validation::active()->set_message('unique', ':label must be unique.');
- return ! ($result->count() > 0);
- }
- public static function _validation_billing_address($val)
- {
- if(empty($val['inactive']))
- {
- if(empty($val['add1']))
- {
- Validation::active()->set_message('billing_address', 'The field Address is required for :label');
- return false;
- }
- if(empty($val['city']))
- {
- Validation::active()->set_message('billing_address', 'The field City is required for :label');
- return false;
- }
- if(empty($val['code']))
- {
- Validation::active()->set_message('billing_address', 'The field Postcode is required for :label');
- return false;
- }
- if(empty($val['country']))
- {
- Validation::active()->set_message('billing_address', 'The field Country is required for :label');
- return false;
- }
- }
- return true;
- }
- public static function _validation_currency($val)
- {
- if(!empty($val))
- {
- if(!is_numeric($val) && !preg_match('/\b\d{1,3}(?:,?\d{3})*(?:\.\d{2})?\b/', $val))
- {
- Validation::active()->set_message('currency', 'The field :label currency format is invalid');
- return false;
- }
- }
- return true;
- }
- public static function _validation_location($val)
- {
- if(empty($val['add1']))
- {
- Validation::active()->set_message('location', 'The Address field is required for :label');
- return false;
- }
- if(empty($val['city']))
- {
- Validation::active()->set_message('location', 'The Town / City field is required for :label');
- return false;
- }
- if(empty($val['code']))
- {
- Validation::active()->set_message('location', 'The Postal / Zip code field is required for :label');
- return false;
- }
- if(empty($val['country']))
- {
- Validation::active()->set_message('location', 'The Country field is required for :label');
- return false;
- }
- return true;
- }
- }
Add Comment
Please, Sign In to add comment