public function validates($entity, $options = [])
    {
        $fieldname = $this->name();

        if (!isset($entity->{$fieldname})) {
            return true;
        }
        return $entity->{$fieldname}->validates($options);
    }
public function validates($entity, $options = [])
    {
        $fieldname = $this->name();

        if (!isset($entity->{$fieldname})) {
            return true;
        }
        return $entity->{$fieldname}->validates($options);
    }
public function validates ( $ entity , $ options = [ ] ) { $ fieldname = $ this -> name ( ) ; if ( ! isset ( $ entity -> { $ fieldname } ) ) { return true ; } return $ entity -> { $ fieldname } -> validates ( $ options ) ; }
Check if an entity is valid or not.

@param  object  $entity  The relation's entity.
@param  array   $options The validation options.
@return boolean
Check if an entity is valid or not .