public function getValidatorInstance() { $validator = parent::getValidatorInstance(); $validator->after(function () use($validator) { // validate destinations $destinations = $this->json('destinations'); if ($destinations) { if (is_array($destinations)) { $offset = 0; foreach ($destinations as $destination) { if (!isset($destination['address']) or !isset($destination['amount'])) { $validator->errors()->add('destinations', 'Missing address or amount for destination ' . ($offset + 1) . '.'); continue; } if (!AddressValidator::isValid($destination['address'])) { $validator->errors()->add('destinations', 'The address for destination ' . ($offset + 1) . ' was invalid.'); } if (!is_numeric($destination['amount']) or CurrencyUtil::valueToSatoshis($destination['amount']) <= 0) { $validator->errors()->add('destinations', 'The amount for destination ' . ($offset + 1) . ' was invalid.'); } ++$offset; } } else { $validator->errors()->add('destinations', 'The destinations were invalid.'); } } }); return $validator; }
public function getValidatorInstance() { $validator = parent::getValidatorInstance(); $validator->sometimes('asset', 'required|alpha|min:3', function ($input) { return !$input->close; }); $validator->sometimes('quantity', 'required|numeric|min:0|notIn:0', function ($input) { return !$input->close; }); $validator->after(function () use($validator) { // if close, don't allow asset or quantity if ($this->input('close')) { if ($this->input('asset')) { $validator->errors()->add('asset', 'The asset field is not allowed when closing an account.'); } if ($this->input('quantity')) { $validator->errors()->add('quantity', 'The quantity field is not allowed when closing an account.'); } } else { if ($this->input('asset') and !$this->input('quantity')) { $validator->errors()->add('quantity', 'The quantity field is required when specifying an asset.'); } if ($this->input('quantity') and !$this->input('asset')) { $validator->errors()->add('asset', 'The asset field is required when specifying a quantity.'); } if (!$this->input('quantity') and !$this->input('asset') and !$this->input('txid')) { $validator->errors()->add('txid', 'Either quantity and asset or a transaction ID is required.'); } } }); return $validator; }
public function getValidatorInstance() { $validator = parent::getValidatorInstance(); $validator->after(function () use($validator) { // validate destination $destination = $this->json('destination'); if (!AddressValidator::isValid($destination)) { $validator->errors()->add('destination', 'The destination was invalid.'); } }); return $validator; }
public function getValidatorInstance() { $validator = parent::getValidatorInstance(); $validator->after(function () use($validator) { // validate address $address = $this->json('address'); Log::info("\$address={$address} AddressValidator::isValid({$address})=" . AddressValidator::isValid($address)); if (!AddressValidator::isValid($address)) { $validator->errors()->add('address', 'The address was invalid.'); } }); return $validator; }
public function getValidatorInstance() { $validator = parent::getValidatorInstance(); // $validator->after(function () use ($validator) // { // // validate address // $address = $this->get('address'); // if (!AddressValidator::isValid($address)) { // $validator->errors()->add('address', 'The address was invalid.'); // } // }); return $validator; }