Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Re-add validation. Update composer deps.
Browse files Browse the repository at this point in the history
  • Loading branch information
CraigChilds94 committed Mar 5, 2018
1 parent a3dff72 commit 7064244
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
24 changes: 19 additions & 5 deletions anchor/routes/variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,30 @@
});

Route::post('admin/extend/variables/edit/(:any)', function ($key) {
$input = Input::get(['key', 'value']);
$input = Input::get(['key', 'value']);

$key = $input['key'] = 'custom_' . slug($input['key'], '_');
$value = $input['value'];
$original = slug($input['key'], '_');

$validator = new Validator($input);

// include prefix length 'custom_'
$validator->add('valid_key', function ($str) use ($original) {

// Don't check against the same key
if ($str == $original) {
return true;
}

return Query::table(Base::table('meta'))
->where('key', '=', $str)
->count() == 0;
});

$validator->check('key')
->is_max(8, __('extend.name_missing'));
->is_max(1, __('extend.name_missing'))
->is_valid_key(__('extend.name_exists'));

$key = $input['key'] = 'custom_' . $original;
$value = $input['value'];

if ($errors = $validator->errors()) {
Input::flash();
Expand Down
20 changes: 10 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7064244

Please sign in to comment.