本文整理汇总了PHP中Result::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP Result::addError方法的具体用法?PHP Result::addError怎么用?PHP Result::addError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Result
的用法示例。
在下文中一共展示了Result::addError方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddErrorsSetsErrorCount
/**
* @depends testAddErrors
* @covers W3C\Validation\Result::getErrorCount
*/
public function testAddErrorsSetsErrorCount()
{
$this->assertEquals(0, $this->result->getErrorCount());
$this->result->addError(new Violation());
$this->assertEquals(1, $this->result->getErrorCount());
$this->result->addError(new Violation());
$this->assertEquals(2, $this->result->getErrorCount());
}
示例2: run
public function run(Result $result, $offset)
{
$result->addError($offset);
$result->addSuccesses(15);
$result->addFailures(10);
return $result;
}
示例3: the_result_correctly_reports_whether_or_not_it_is_valid
/**
* @group response-validation
* @test
*/
public function the_result_correctly_reports_whether_or_not_it_is_valid()
{
$result = new Result();
$this->assertTrue($result->isValid());
$this->assertCount(0, $result->getErrors());
$result->addError('Oh noooos!');
$this->assertFalse($result->isValid());
$this->assertCount(1, $result->getErrors());
}
示例4: Result
function validate_cancel_input()
{
$result = new Result();
if (!isset($_POST['leave_to_cancel']) || empty($_POST['leave_to_cancel'])) {
$result->setResult(FALSE);
$result->addError("Please select leave to cancel");
}
return $result;
}
示例5: add
/**
* Добавление сущности
*
* @param $data
*/
public function add($data)
{
$data = $this->factoryEntity($data)->toArray();
// Фильтруем данные
$data = $this->filterOnAdd($data);
// Валидируем данные
$validator = $this->validateOnAdd($data);
$result = new Result();
if ($validator->isValid()) {
try {
$id = $this->insert($this->getName(), $data);
if (!$id) {
$result->addError('Add ' . $this->getName() . ' failed', 'add_product_failed');
}
} catch (Exception $e) {
$result->addError($e->getMessage(), $e->getCode());
}
}
return $result->setResult($id);
}
示例6: validate
/**
* Validates the given markup
*
* @param string $markup
*
* @return Result
*/
public function validate($markup)
{
$result = new Result();
$messages = $this->processor->execute($markup);
foreach ($messages as $message) {
if (Validator::MESSAGE_TYPE_ERROR === $message['type']) {
$result->addError(new Error($message['line'], $message['column'], $message['message']));
} else {
if (Validator::MESSAGE_TYPE_WARNING === $message['type']) {
$result->addWarning(new Warning($message['line'], $message['column'], $message['message']));
}
}
}
return $result;
}
示例7: validateValue
public function validateValue($value, $primary, $row, Result $result)
{
$validators = $this->getValidators();
foreach ($validators as $validator) {
if (is_object($validator)) {
$vResult = $validator->validate($value, $primary, $row, $this);
} else {
$vResult = call_user_func_array($validator, array($value, $primary, $row, $this));
}
if ($vResult !== true) {
$result->addError(new FieldError($this, $vResult, FieldError::INVALID_VALUE));
break;
}
}
}
示例8: Result
function is_valid_casual_leave($emp_id, $leave_start_date, $leave_end_date)
{
$result = new Result();
// check if leave is comming into already taken leaves period
$this->load->model('leave/leave_helper', 'lh');
$clash_verification = $this->lh->verify_leaves_period($emp_id, $leave_start_date, $leave_end_date);
$result->updateResult($clash_verification);
// check if valid balance of casual leaves
$avail_bal = $this->get_casual_leave_balance($emp_id);
$applied_period = strtotime($leave_end_date) - strtotime($leave_start_date);
$applied_period = floor($applied_period / (60 * 60 * 24)) + 1;
if ($avail_bal < $applied_period) {
$result->setResult(FALSE);
$error = "Your leave length is more than available balance. " . "Your available casual leave balance is " . $avail_bal;
$result->addError($error);
}
// check for maximum allowed casual leaves in one stretch
if ($applied_period > 5) {
$result->setResult(FALSE);
$error = "You can take atmost 5 casual leaves in one stretch.";
$result->addError($error);
}
return $result;
}
示例9: Result
function is_valid_restricted_leave($emp_id, $leave_date)
{
$result = new Result();
// modify date to match db date format
$leave_date = date('Y-m-d', strtotime($leave_date));
// check if restricted holiday available
$sql = "SELECT * FROM " . Leave_constants::$TABLE_RESTRICTED_HOLIDAYS . " WHERE holiday_date = '{$leave_date}'";
$query = $this->db->query($sql);
if ($query->num_rows() == 0) {
$result->setResult(FALSE);
$result->addError("No restricted holiday available.");
}
// check if leave is comming into already taken leaves period
$this->load->model('leave/leave_helper', 'lh');
$clash_verification = $this->lh->verify_leaves_period($emp_id, $leave_date, $leave_date);
$result->updateResult($clash_verification);
// check if balance for leave available
$balance = $this->get_restricted_leave_balance($emp_id);
if ($balance < 1) {
$result->setResult(FALSE);
$result->addError("Your don't have restricted leaves left.");
}
return $result;
}
示例10: Result
function check_for_weekend()
{
// result to resturn
$result = new Result();
$time = $this->leave_start_time;
while ($this->leave_end_time >= $time) {
$day_of_week = date('w', $time);
if ($day_of_week == 0 || $day_of_week == 6) {
$result->setResult(FALSE);
$result->addError("Your leave includes weekend(s) please break it around them.");
break;
}
$time += 24 * 60 * 60;
}
return $result;
}
示例11: Result
function is_valid_date_field()
{
// validate emptiness and format of date
// start date <= end date
// start date > todays date
// start date must be less than 3 months from today
// result to return
$result = new Result();
// check for valid start date
$start_date = strtotime($_POST[Leave_application::LEAVE_START_DATE]);
if (empty($start_date) || $start_date == FALSE) {
$result->setResult(FALSE);
$result->addError("Invalid start date format. It should be in format mm/dd/yyyy");
}
// check for valid end date if not restricted leave
if (Leave_constants::$TYPE_RESTRICTED_LEAVE != $_POST[Leave_application::LEAVE_TYPE]) {
// check for empty or invalid date field
$end_date = strtotime($_POST[Leave_application::LEAVE_END_DATE]);
if (empty($end_date) || $end_date == FALSE) {
$result->setResult(FALSE);
$result->addError("Invalid end date format. It should be in format mm/dd/yyyy");
}
// check if start date <= end date
$diff = $end_date - $start_date;
if ($diff < 0) {
$result->setResult(FALSE);
$result->addError("End date can not be before start date. Valid date format mm/dd/yyyy");
}
}
// check if start date > todays date
$today = strtotime(date('Y-m-d'));
$diff = $start_date - $today;
if ($diff <= 0) {
$result->setResult(FALSE);
$result->addError("Start date should be after today's date. Valid date format mm/dd/yyyy");
}
// leave can be applied only before 90 days from today
$three_months_time = 90 * 24 * 60 * 60;
if ($diff > $three_months_time) {
$result->setResult(FALSE);
$result->addError("Leave can be applied within 90 days from today");
}
return $result;
}