Skip to content

Always getting true when validating #18

Description

@DannyBen

This is definitely something simple I am missing, but I am unable to make the validate or isValid methods return false.

    // Test 1: 
    $data   = "asd";
    $schema = json_encode(["type" => "object"]);
    $result = Jsv4::validate($data, $schema);
    print_r($result);
    // Jsv4 Object
    // (
    //     [data:Jsv4:private] => asd
    //     [schema:Jsv4:private] => {"type":"object"}
    //     [firstErrorOnly:Jsv4:private] => 
    //     [coerce:Jsv4:private] => 
    //     [valid] => 1
    //     [errors] => Array()
    // )

    // Test 2: 
    $data   = json_encode(["name" => 23]);
    $schema = json_encode(["properties" => ["name" => ["type" => "string"]]]);
    $result = Jsv4::validate($data, $schema);
    print_r($result);
    // Jsv4 Object
    // (
    //     [data:Jsv4:private] => {"name":23}
    //     [schema:Jsv4:private] => {"properties":{"name":{"type":"string"}}}
    //     [firstErrorOnly:Jsv4:private] => 
    //     [coerce:Jsv4:private] => 
    //     [valid] => 1
    //     [errors] => Array()
    // )

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions