public function build($ruleset = null): Validator
    {
        $validators = array_merge([], $this->validators);
        if (is_object($ruleset) || (is_array($ruleset) && Parser::isAssociative($ruleset))) {
            foreach ($ruleset as $field => $rules) {
                $validators[$field] = $this->parser->parse($rules);
            }
        }
        return new Validator($validators);
    }
public function build($ruleset = null): Validator
    {
        $validators = array_merge([], $this->validators);
        if (is_object($ruleset) || (is_array($ruleset) && Parser::isAssociative($ruleset))) {
            foreach ($ruleset as $field => $rules) {
                $validators[$field] = $this->parser->parse($rules);
            }
        }
        return new Validator($validators);
    }
public function build ( $ ruleset = null ) : Validator { $ validators = array_merge ( [ ] , $ this -> validators ) ; if ( is_object ( $ ruleset ) || ( is_array ( $ ruleset ) && Parser :: isAssociative ( $ ruleset ) ) ) { foreach ( $ ruleset as $ field => $ rules ) { $ validators [ $ field ] = $ this -> parser -> parse ( $ rules ) ; } } return new Validator ( $ validators ) ; }
Builds a validator for the provided ruleset.

```javascript
// rules.json
{
name: 'required',
email: ['required', 'email'],
drinks: { one_of: [['coffee', 'tea']] },
phone: {max_length: 10}
}
```
```php
$ruleset = json_decode(file_get_contents('rules.json'));
$builder = new \Caridea\Validate\Builder();
$validator = $builder->build($ruleset);
```

@param object|array $ruleset Object or associative array (as returned
from `json_decode`) with ruleset, or `null` to use defined rules.
@return \Caridea\Validate\Validator the built validator
Builds a validator for the provided ruleset .