fix: [lax URL validation] added for Broodstable

- can be reused elsewhere too
- allows for http://hostname style urls
cli-modification-summary
iglocska 2022-01-26 14:57:43 +01:00
parent f695744bd7
commit 519fcd2b1a
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
2 changed files with 10 additions and 1 deletions

View File

@ -46,4 +46,9 @@ class AppTable extends Table
}
}
}
public function isValidUrl($value, array $context): bool
{
return filter_var($value, FILTER_VALIDATE_URL);
}
}

View File

@ -33,7 +33,11 @@ class BroodsTable extends AppTable
->requirePresence(['name', 'url', 'organisation_id'], 'create')
->notEmptyString('name')
->notEmptyString('url')
->url('url', __('The provided value is not a valid URL'))
->add('url', 'isValidUrl', [
'rule' => 'isValidUrl',
'message' => __('The provided value is not a valid URL'),
'provider' => 'table'
])
->naturalNumber('organisation_id', false);
}