Currently the validator will not run validation rules for empty values:
$rules = ['age' => 'integer'];
$input = json_decode('{"age": null}', true);
Validator::make($input, $rules)->passes(); // true
openapi: 3.0.0 | |
info: | |
version: 1.0.0 | |
title: Matt's Bicycle Shop API | |
servers: | |
- url: http://api.matts-bikes.dev/v1 | |
paths: | |
/work-orders: | |
post: | |
summary: Create a work order |
<?php | |
abstract class ServiceProvider implements DefinitionSource | |
{ | |
/** | |
* @return array | |
*/ | |
abstract protected function definitions(): array; | |
/** |
_composer_scripts() { | |
local cur="${COMP_WORDS[COMP_CWORD]}" | |
local scripts=$(composer run-script -l --no-ansi 2> /dev/null | awk '/^ +[a-z]+/ { print $1 }') | |
COMPREPLY=( $(compgen -W "${scripts}" -- ${cur}) ) | |
return 0 | |
} | |
complete -F _composer_scripts composer |
<?php | |
function likeToRegex($like) | |
{ | |
// replace all % characters that are not escaped with .* | |
$regex = preg_replace('/(?<!\\\)%/', '.*', $like); | |
// replace all escaped % characters with % | |
$regex = str_replace('\%', '%', $regex); | |
// replace all unescaped _ characters with .{1} | |
$regex = preg_replace('/(?<!\\\)_/', '.{1}', $regex); |
$.ajax({ | |
method: POST, | |
url: my.app.dev/users/1, | |
data: { name: "Matt"} | |
}) | |
.done(function () { | |
// whatever you normally do here | |
}) | |
.fail(function (res) { | |
if (res.status !== 422) { |
Currently the validator will not run validation rules for empty values:
$rules = ['age' => 'integer'];
$input = json_decode('{"age": null}', true);
Validator::make($input, $rules)->passes(); // true
<?php | |
$stream = new GuzzleHttp\Psr7\MultipartStream([['name' => 'some-file', 'contents' => 'the contents']]); | |
$client = new GuzzleHttp\Client(); | |
$r = $client->request('POST', 'http://httpbin.org/post', ['body' => $stream]); | |
$r->getBody()->getContents(); | |
=> """ | |
{\n | |
"args": {}, \n | |
"data": "", \n | |
"files": {}, \n |
<?php | |
// Open the stream | |
$numbers = fopen(__DIR__ . '/numbers.txt', 'r'); | |
// Wrap our parser in an infinite loop, so it won't stop until we say so | |
while (true) { | |
// Read a line | |
$buffer = fgets($numbers); | |
// The docs say it will return false when there arent any bytes left, | |
// so we break out of our loop and let the sript die when that happens. |
# Makefile for ESP8266 projects | |
# | |
# Note: This Makefile has all the libs for the IoT_Demo | |
# | |
# Thanks to: | |
# - zarya | |
# - Jeroen Domburg (Sprite_tm) | |
# - Christian Klippel (mamalala) | |
# - Tommie Gannert (tommie) | |
# |
cd /tmp/ | |
uname -r | |
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18-vivid/linux-headers-3.18.0-031800-generic_3.18.0-031800.201412071935_amd64.deb | |
uname -r | |
cd /tmp | |
sudo mkdir kernel | |
cd kernel/ | |
cd ../ | |
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18-vivid/linux-headers-3.18.0-031800-generic_3.18.0-031800.201412071935_amd64.deb | |
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18-vivid/linux-headers-3.18.0-031800_3.18.0-031800.201412071935_all.deb |