public function test_validating_Jalali_fails_with_farsi_locale() { $this->translator->setLocale('fa'); JalaliValidator::setSampleDate(new JalaliDate(1395, 2, 13)); $validator = $this->factory->make(['graduation_date' => 'foo', 'birth_date' => 'bar'], ['graduation_date' => 'required|jalali:y/M/d', 'birth_date' => 'required|jalali']); $this->assertTrue($validator->fails()); $this->assertEquals(['graduation_date' => ['graduation date وارد شده تاریخ شمسی معتبری طبق فرمت y/M/d نیست (مثال معتبر: ۹۵/اردیبهشت/۱۳).'], 'birth_date' => ['تاریخ تولد وارد شده تاریخ شمسی معتبری طبق فرمت Y/m/d نیست (مثال معتبر: ۱۳۹۵/۲/۱۳).']], $validator->messages()->toArray()); JalaliValidator::setSampleDate(); }
public function test_validate_before_with_date_and_format() { $now = '1394-9-13'; $tomorrow = '1394-9-14'; $yesterday = '1394-9-12'; $this->assertFalse($this->validator->validateBefore('foo', $tomorrow, [$now, 'Y-m-d'])); $this->assertTrue($this->validator->validateBefore('foo', $yesterday, [$now, 'Y-m-d'])); $this->assertFalse($this->validator->validateBefore('foo', $now, [$now, 'Y-m-d'])); $this->assertFalse($this->validator->validateBefore('foo', 'bar', [$now, 'Y-m-d'])); }