Skip to content

Commit

Permalink
[v1.0.9] harden the validation code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
sassman committed May 3, 2019
1 parent 5dedefa commit 5894586
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog

## 1.0.9

- more robust validation of nullable values

## 1.0.8

- migrate to pedantic package for linting
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,6 +1,6 @@
name: valgene_cli
description: Valgene (Validation Generator) generates validator and Dto boiler plate code from your OpenAPI specs.
version: 1.0.8
version: 1.0.9
homepage: https://github.com/valgene/valgene-cli
author: Sven Assmann <sven@d34dl0ck.me>

Expand Down
3 changes: 3 additions & 0 deletions templates/php5.5/{{endpoint}}/{{name}}DtoValidator.php
Expand Up @@ -38,6 +38,9 @@ public function validate($json)
protected function {{ validationMethodName }}($json, $isRequired)
{
$field = {{ name }}Dto::{{{ asConst }}};
if($isRequired && !is_array($json)) {
throw new MissingFieldException($field, $json);
}
if (!array_key_exists($field, $json)) {
if ($isRequired) {
throw new MissingFieldException($field, $json);
Expand Down

0 comments on commit 5894586

Please sign in to comment.