Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Added hex-color rule #19

Merged
merged 4 commits into from
Apr 29, 2020
Merged

Added hex-color rule #19

merged 4 commits into from
Apr 29, 2020

Conversation

innoflash
Copy link
Contributor

@innoflash innoflash commented Apr 28, 2020

This PR aims to add hex-code color validation.

Simple to use as :

use Axiom\Rules\HexColor;


$request->validate([
   'myColor' => [new HexColor]
]);

All hex colors should start with # like #000

@mattkingshott
Copy link
Contributor

Thanks for contributing!

A few things:

  1. Pull requests without descriptions are not ideal. Even a simple description is helpful.
  2. I'm happy to merge this, but it will require a test first. Otherwise I have no idea if the code does what it claims to do.
  3. You will need to update the readme to give users a description about the rule.

Thanks again!

@innoflash
Copy link
Contributor Author

Copy that, will update all

@mattkingshott
Copy link
Contributor

Thanks for the updates. Much appreciated!

Couple of things:

  1. Could you please add doc blocks to the rule class methods (see another rule for what they should be) and also add a docblock for the pregMatchArray property. I also think this property should maybe be renamed to 'formats' just so it is clearer exactly what it is.

  2. Also, an observation. I believe you can use a hex code of 5 characters for colors e.g. Fixed Class 'Str' not found #5. Works for me in the browser at least. It's a shorthand for hex with opacity. I think the rule should be updated to allow for that.

Thanks again, I appreciate your efforts :)

@innoflash
Copy link
Contributor Author

on it

@innoflash
Copy link
Contributor Author

I am not sure of the 5 digit hex code but i cant seem to find it online and on PHPStorm its found to be an error.
Screenshot from 2020-04-29 12-08-05

@mattkingshott
Copy link
Contributor

OKay, I think it is non-standard anyway. If you want to validate, you probably want to ensure full hex codes.

@mattkingshott mattkingshott merged commit cabfd81 into caneara:master Apr 29, 2020
@mattkingshott
Copy link
Contributor

Thanks!

@innoflash innoflash deleted the hex-color branch April 29, 2020 10:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants