Wixel / GUMP

A fast, extensible & stand-alone PHP input validation class that allows you to validate any data
https://wixelhq.com
MIT License
1.17k stars 341 forks source link

Add has_validator and has_filter method #348

Closed chaungoclong closed 4 months ago

chaungoclong commented 5 months ago

This method checks if a validator method exists for a given rule.

The reason for adding this method is to prevent exceptions from being thrown when using the add_validator method with a rule that already exists. By using has_validator, we can ensure that a rule does not exist before adding it.

Here are the key changes:

  1. New Method: The has_validator method takes a rule as a string parameter and returns a boolean value. It checks if a validator method exists for the given rule in the Validator class or if the rule is present in the validation_methods array.

  2. Test Cases: Test cases for both happy and unhappy paths have been included to validate the functionality of the new has_validator method.

filisko commented 5 months ago

Hi @chaungoclong . Perhaps has_filter would be also nice to add?

chaungoclong commented 5 months ago

Hi @filisko , Thanks for the suggestion! I can add the has_filter method in this pull request along with has_validator. I'll get started on it.

filisko commented 4 months ago

Added more stuff here #351