Coder Social home page Coder Social logo

Comments (7)

RhysLees avatar RhysLees commented on July 21, 2024 1

I agree and you beat me to creating an issue for it!

If I get time this week I might make a PR

from novapackages.

marcusmoore avatar marcusmoore commented on July 21, 2024

I agree and you beat me to creating an issue for it!

from novapackages.

RhysLees avatar RhysLees commented on July 21, 2024

@marcusmoore If you could point me to the file where its best to trim the names ill submit a pr.

from novapackages.

marcusmoore avatar marcusmoore commented on July 21, 2024

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 😄 )

from novapackages.

RhysLees avatar RhysLees commented on July 21, 2024

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.

from novapackages.

marcusmoore avatar marcusmoore commented on July 21, 2024

Thanks and no rush @RhysLees 😄

I don't know if I want to reject a package that includes the version in the title but I think we should be more clear about how we determine v4 support. I opened an issue to track that here: #218

from novapackages.

RhysLees avatar RhysLees commented on July 21, 2024

Thanks and no rush @RhysLees 😄

I don't know if I want to reject a package that includes the version in the title but I think we should be more clear about how we determine v4 support. I opened an issue to track that here: #218

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".';
    }

from novapackages.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.