Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
973fb07
feat: add schemas package and datafile sections for modules
fahad19 Nov 27, 2026
7cf5599
fix: read $, \s and the dot in conditions as JavaScript does
fahad19 Nov 27, 2026
c438d3b
feat(schemas): read patterns with the u flag and fail closed as JavaS…
fahad19 Nov 27, 2026
32dddad
fix(cli): read segment definitions that carry metadata
fahad19 Nov 27, 2026
9877dfe
feat: evaluate package entries with module phases, as getters do
fahad19 Nov 27, 2026
90db33a
feat(cli): run schema specs with featurevisor-schemas
fahad19 Nov 27, 2026
b430f15
docs: follow the JavaScript SDK page in the README
fahad19 Nov 28, 2026
c242bac
feat: changed keys in context_set and segments in datafile_set
fahad19 Nov 28, 2026
c2d1b08
perf: work out datafile_set details only for someone who reads them
fahad19 Nov 28, 2026
f75b4a3
fix: read the README example under its new heading
fahad19 Nov 28, 2026
5784728
refactor(schemas): keep child, getFieldKeys, hasChecks and validateRu…
fahad19 Nov 28, 2026
35cbcf5
refactor(schemas): drop validateRules and hasChecks, which nothing ca…
fahad19 Nov 28, 2026
1ba5ed3
test(schemas): a default annotation, and one a mutation sets
fahad19 Nov 29, 2026
2dfdc34
docs(schemas): the default annotation in Read annotations
fahad19 Nov 29, 2026
0675255
feat(schemas): issues entries wait only for the fields they compare, …
fahad19 Nov 29, 2026
917ded4
refactor(schemas): follow the simplified JavaScript package
fahad19 Nov 29, 2026
7670c75
docs: beforeEvaluation runs for a schema validation too
fahad19 Nov 29, 2026
473fc0a
fix(schemas): follow the JavaScript release fixes
fahad19 Nov 30, 2026
9793b78
refactor(schemas): a field's handle comes from field(path), not at(path)
fahad19 Nov 30, 2026
dbd9ca8
refactor(schemas): a handle says what a field renders as with getRend…
fahad19 Nov 30, 2026
0bf906d
chore(release): 5.1.0
fahad19 Nov 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,191 changes: 643 additions & 548 deletions README.md

Large diffs are not rendered by default.

931 changes: 931 additions & 0 deletions conformance/schemas-datafile.json

Large diffs are not rendered by default.

4,521 changes: 4,521 additions & 0 deletions conformance/schemas-validation.json

Large diffs are not rendered by default.

768 changes: 768 additions & 0 deletions conformance/sdk-conditions.json

Large diffs are not rendered by default.

1,104 changes: 1,104 additions & 0 deletions conformance/sdk-events.json

Large diffs are not rendered by default.

460 changes: 460 additions & 0 deletions conformance/sdk-package-conditions.json

Large diffs are not rendered by default.

941 changes: 941 additions & 0 deletions conformance/sdk-sections.json

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions featurevisor-schemas/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.featurevisor</groupId>
<artifactId>featurevisor-parent</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>featurevisor-schemas</artifactId>
<packaging>jar</packaging>

<name>Featurevisor Schemas for Java</name>
<description>Validate data against the schemas a Featurevisor datafile carries</description>
<url>https://github.com/featurevisor/featurevisor-java</url>

<scm>
<connection>scm:git:git://github.com/featurevisor/featurevisor-java.git</connection>
<developerConnection>scm:git:ssh://github.com:featurevisor/featurevisor-java.git</developerConnection>
<url>https://github.com/featurevisor/featurevisor-java</url>
<tag>HEAD</tag>
</scm>

<dependencies>
<dependency>
<groupId>com.featurevisor</groupId>
<artifactId>featurevisor-java</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<!-- The SDK's test runner CLI, run from this module so schema specs validate. Not published as dependencies. -->
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-exec</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<directory>${project.basedir}/../conformance</directory>
<targetPath>conformance</targetPath>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
<plugin>
<!-- exec:java runs the CLI with the test classpath, which holds the CLI's own dependencies. -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<classpathScope>test</classpathScope>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.featurevisor.schemas;

import java.util.Map;

/** What a check in code gets besides the value at its path. */
public final class CheckInfo {
private final Object input;
private final Map<String, Object> context;

CheckInfo(Object input, Map<String, Object> context) {
this.input = input;
this.context = context;
}

/**
* The whole value being validated, as maps, lists and primitives. For a
* search or a lookup outside validation, the values {@code withInput} gave,
* or null without them.
*/
public Object getInput() { return input; }

/** The context validation uses: the instance's, with any given to the call merged over it. */
public Map<String, Object> getContext() { return context; }

/** The value at a path in the input, such as {@code password} or {@code items.0.name}, or null. */
public Object read(String path) {
Object current = input;
for (Paths.Step step : Paths.parse(path)) {
if (step.kind == Paths.Kind.KEY && current instanceof Map) current = ((Map<?, ?>) current).get(step.key);
else if (step.kind == Paths.Kind.INDEX && current instanceof java.util.List
&& step.index < ((java.util.List<?>) current).size()) current = ((java.util.List<?>) current).get(step.index);
else return null;
}
return current;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.featurevisor.schemas;

import com.featurevisor.cli.SchemaSpecValidator;
import com.featurevisor.sdk.Featurevisor;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/** Lets the SDK's CLI run schema specs, found through {@link java.util.ServiceLoader}. */
public final class CliSchemaSpecValidator implements SchemaSpecValidator {
@Override
public List<Map<String, Object>> validate(Featurevisor f, String schema, Object value) {
Schemas schemas = Schemas.create(f);
try {
List<Map<String, Object>> issues = new ArrayList<>();
for (SchemaIssue issue : schemas.validate(schema, value).getIssues()) {
// An issue as a test result shows it, without the schema key every issue repeats.
Map<String, Object> described = new LinkedHashMap<>();
described.put("path", issue.getPath());
described.put("code", issue.getCode());
if (issue.getMutation() != null) described.put("mutation", issue.getMutation());
described.put("message", issue.getMessage());
described.put("params", issue.getParams());
issues.add(described);
}
return issues;
} finally {
schemas.close();
}
}
}
Loading