Skip to content
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

Full stops in SKUs #874

Closed
ryanmitchell opened this issue Feb 22, 2023 · 10 comments
Closed

Full stops in SKUs #874

ryanmitchell opened this issue Feb 22, 2023 · 10 comments
Labels
enhancement Improvement to existing functionality

Comments

@ryanmitchell
Copy link
Contributor

SKUs on product variants have a validation rule of alpha_dash but we have a need to include dots in the SKU based on what a supplier is providing.

Can the validation rule either be updated to accommodate this or can it be extendable to allow the rules to be defined by a dev?

@ryanmitchell ryanmitchell added the enhancement Improvement to existing functionality label Feb 22, 2023
@glennjacobs
Copy link
Contributor

Maybe we should allow for more options in the current config? At the moment we allow SKU to be required or not, and unique or not. Guess we could also add the validation type?

Maybe there's a better approach to customising validation long-term, but I guess it would do for now?

@ryanmitchell
Copy link
Contributor Author

Yeah it might be worth letting devs override the alpha_num validation type if they want and let them specify their own validation rules?

@glennjacobs
Copy link
Contributor

Yep. If you want to do a PR feel free.

@alecritson
Copy link
Collaborator

Just to jump in on this, it is actually possible, it's on 0.2 so I don't think it's in the current docs.

Lunar\Hub\Http\Livewire\Components\Products\ProductCreate::extendValidation([
    'variant.sku' => ['required', 'min:8'],
]);

Lunar\Hub\Http\Livewire\Components\Products\ProductShow::extendValidation([
    'variant.sku' => ['required', 'min:8'],
]);

Lunar\Hub\Http\Livewire\Components\Products\Variants\VariantShow::extendValidation([
    'variant.sku' => ['required', 'min:8']
]);

@glennjacobs
Copy link
Contributor

@alecritson is this in the docs? I had a look at https://docs-next.lunarphp.io/ but can't see it.

@alecritson
Copy link
Collaborator

Not sure how docs-next works, but docs were added for it on the PR #443

@ryanmitchell
Copy link
Contributor Author

Thanks @alecritson !

@glennjacobs
Copy link
Contributor

Not sure how docs-next works, but docs were added for it on the PR #443

They run off the 0.2 branch.

@glennjacobs
Copy link
Contributor

Found it https://github.com/lunarphp/lunar/blob/0.2/docs/src/extending/validations.md

It hasn't been added to the side menu, hence it can't be found.

@glennjacobs
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants