Skip to content

Conversation

@vtsykun
Copy link
Contributor

@vtsykun vtsykun commented Oct 15, 2017

Fix ticket #63

@vtsykun vtsykun force-pushed the meta-name-validation branch from 22886a9 to 6737188 Compare October 15, 2017 14:28
@vtsykun vtsykun force-pushed the meta-name-validation branch from 6737188 to 4842fff Compare October 15, 2017 14:32

private function isValidMemberName(string $name): bool
{
return preg_match('/^(?=[^-_ ])[a-zA-Z0-9\x{0080}-\x{FFFF}-_ ]*(?<=[^-_ ])$/u', $name) === 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this line is duplicated here and in ResourceObject.I suggest we move this check into a trait unless we can figure out a better solution


private function validateObject($object)
{
foreach ($object as $name => $value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if $object implements Iterator and the keys and values exposed by Iterator interface are different from its JSON representation. We may perhaps do json_encode right in the constructor, then convert it back to an array with json_decode(), and then check the keys of the resulting array.

@f3ath
Copy link
Contributor

f3ath commented Oct 15, 2017

Hi @vtsykun, thanks for the PR. I left a couple of comment in the code. Please let me know what you think.

@f3ath f3ath merged commit 825b828 into json-api-php:master Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants