$validator ->requirePresence('age') ->notEmptyString('age') ->add('age', 'numeric', [ 'rule' => 'numeric', 'message' => 'Age must be a number' ]);
$validator ->requirePresence('score') ->greaterThan('score', 0, 'Score must be a positive number') ->lessThanOrEqual('score', 100, 'Score must be between 0 and 100');In this example, we're validating a "score" field and adding two rules to ensure that the value is between 0 and 100 (inclusive). The "greaterThan" rule ensures that the value is greater than 0 and the "lessThanOrEqual" rule ensures that the value is less than or equal to 100. The Validator component is part of the CakePHP framework, which is a PHP web development framework that provides a set of libraries and tools for building web applications.