Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8f10f7b
Исправил падение при формировании сообщения об ошибке
arheyy Aug 6, 2018
8915aa9
Merge pull request #22 from eLama/fix_error_handling
arheyy Aug 6, 2018
befe7a4
Добавил поддержку дат в queryParameters
arheyy Sep 13, 2018
3eda884
Merge pull request #24 from eLama/query_params
arheyy Sep 13, 2018
9ab22e7
Изменения из оригинального репозитория
arheyy Sep 17, 2018
fc3fb0f
Merge remote-tracking branch 'origin/master'
arheyy Sep 17, 2018
566ea16
Изменения из оригинального репозитория
arheyy Sep 17, 2018
a334d6c
Merge branch 'master' into raml-org-master
arheyy Sep 17, 2018
de450fe
Вернул тесты для php5.5
arheyy Sep 17, 2018
e0da049
Вернул конфиг travis
arheyy Sep 17, 2018
25a84ce
Вернул конфиг composer
arheyy Sep 17, 2018
9d3a890
Правки конфигов
arheyy Sep 17, 2018
3a9f638
Merge pull request #27 from eLama/raml-org-master
arheyy Sep 17, 2018
f4416cc
Added inheritance support for union types
arheyy Sep 18, 2018
90d7807
Merge pull request #28 from eLama/union_inheritance
arheyy Sep 18, 2018
c944232
Added dates item type for array type
arheyy Sep 20, 2018
d796fc9
Merge pull request #29 from eLama/array_scalars
arheyy Sep 20, 2018
5a7b823
Fix error with string validation, when input is not a string
arheyy Nov 7, 2018
12cd171
Merge pull request #30 from eLama/string_validation_fix
arheyy Nov 7, 2018
ec912d0
Merge branch 'master' of https://github.com/eLama/php-raml-parser int…
martin-georgiev Jan 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Latest Stable Version](https://poser.pugx.org/raml-org/raml-php-parser/version)](https://packagist.org/packages/raml-org/raml-php-parser)
[![Total Downloads](https://poser.pugx.org/raml-org/raml-php-parser/downloads)](https://packagist.org/packages/raml-org/raml-php-parser)

See the RAML spec here: https://github.com/raml-org/raml-spec
See the [RAML specification](https://github.com/raml-org/raml-spec).

## RAML 0.8 Support
For RAML 0.8 support follow version 2.
Expand Down
3 changes: 1 addition & 2 deletions src/NamedParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,7 @@ public function getMatchPattern()

break;
case self::TYPE_DATE:
// @see https://snipt.net/DamienGarrido/
// http-date-regular-expression-validation-rfc-1123rfc-850asctime-f64e6aa3/
// @see https://snipt.net/DamienGarrido/http-date-regular-expression-validation-rfc-1123rfc-850asctime-f64e6aa3/
$pattern = '^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?:[0-2][0-9]|3[01]) ' .
'(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} ' .
'(?:[01][0-9]|2[0-3]):[012345][0-9]:[012345][0-9] ' .
Expand Down
2 changes: 1 addition & 1 deletion src/Types/DatetimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class DatetimeType extends Type
{
const DEFAULT_FORMAT = DATE_RFC3339;

/**
* DateTime format to use
*
Expand All @@ -23,7 +24,6 @@ class DatetimeType extends Type
*
* @param string $name
* @param array $data
*
* @return DatetimeType
*/
public static function createFromArray($name, array $data = [])
Expand Down
2 changes: 2 additions & 0 deletions src/Types/StringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public function validate($value)

if (!is_string($value)) {
$this->errors[] = TypeValidationError::unexpectedValueType($this->getName(), 'string', $value);

return;
}
if (null !== $this->pattern) {
$pregMatchResult = preg_match('/' . $this->pattern . '/', $value);
Expand Down
5 changes: 2 additions & 3 deletions src/Types/TimeOnlyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ class TimeOnlyType extends Type
/**
* Create a new TimeOnlyType from an array of data
*
* @param string $name
* @param array $data
*
* @param string $name
* @param array $data
* @return TimeOnlyType
*/
public static function createFromArray($name, array $data = [])
Expand Down
22 changes: 15 additions & 7 deletions tests/NamedParameters/ParameterTypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,39 +248,49 @@ public function shouldValidateDate()
$namedParameter->validate('Sun, 06 Nov 1994 08:49:37 BUNS');
}

/** @test */
/**
* @test
*/
public function shouldValidateDateOnly()
{
$this->expectException('\Raml\Exception\ValidationException', 'Expected date-only');
$namedParameter = $this->validateBody->getParameter('date-only');
$namedParameter->validate('2018-08-05T13:24:55');
}

/** @test */
/**
* @test
*/
public function shouldValidateDateTimeOnly()
{
$this->expectException('\Raml\Exception\ValidationException', 'Expected datetime-only');
$namedParameter = $this->validateBody->getParameter('datetime-only');
$namedParameter->validate('2018-08-05T13:24:55+12:00');
}

/** @test */
/**
* @test
*/
public function shouldValidateTimeOnly()
{
$this->expectException('\Raml\Exception\ValidationException', 'Expected time-only');
$namedParameter = $this->validateBody->getParameter('time-only');
$namedParameter->validate('2018-08-05T13:24:55');
}

/** @test */
/**
* @test
*/
public function shouldValidateDateTime()
{
$this->expectException('\Raml\Exception\ValidationException', 'Expected datetime');
$namedParameter = $this->validateBody->getParameter('datetime');
$namedParameter->validate('2018-08-05 13:24:55');
}

/** @test */
/**
* @test
*/
public function shouldValidateDateTimeFormat()
{
$this->expectException('\Raml\Exception\ValidationException', 'Expected datetime with format Y-m-d H:i:s');
Expand All @@ -290,8 +300,6 @@ public function shouldValidateDateTimeFormat()

// ---

/** @test */

/**
* @test
*/
Expand Down