-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove "N4", "v4", "Nova 4", "4", "(4)" From name #212
Comments
I agree and you beat me to creating an issue for it! |
If I get time this week I might make a PR |
@marcusmoore If you could point me to the file where its best to trim the names ill submit a pr. |
It looks like the replacement is happening in the templates. I would like to move that code to a presenter method of some sort so we can have a place to put future replacements and write tests around it. It would be great if you're up for working on it but no pressure (of course 😄 ) |
I'll see what I can do! Just a thought, what if we just make a custom validation rule for name field, that way we don't even save the 'unnecessary data' to db and the user will be displayed an error, which we can tell them to use composer versions to specify support. That would also keep it in one place so we don't duplicate code. |
Ah ok, i was going to recommend the following as a rule. would allow is to return feedback to the user when they create the form. This can also be used with a tiny modification to take it out of the array: /**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
/**
* Any item in the haystack that doesn't contain a string needs to be placed at the bottom
* otherwise it will leave the string before the version number.
*/
$invalidSubstrings = [
'N!',
'V!',
'Nova !',
'Nova!',
'(!)', // Place at bottom
'!', // Place at bottom
];
// The haystack used to check if the string contains any of the invalid substrings.
$versionHaystack = [];
// Create the version haystack for each version of Laravel Nova.
$v = 1;
while ($v <= config('novapackages.nova.latest_major_version')) {
foreach ($invalidSubstrings as $subject) {
// Replace ! with the version number.
$versionHaystack[] = str_replace('!', $v, $subject);
}
$v++;
}
// Filter the value to only contain strings that contain the version number case insensitive.
$filteredVersions = str_ireplace($versionHaystack, '', $value);
// Filter extra spaces created by the removing elements from the version haystack.
$filtered = preg_replace('!\s+!', ' ', $filteredVersions);
return $filtered === $value;
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return 'The :attribute must not reference a Laravel Nova version. Require the version in your "composer.json".';
} |
I think it would be best to remove any mention of version from Package names and instead encourage people to require nova ^4.0 in their composer.json to show support
The text was updated successfully, but these errors were encountered: