Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into fix/1432
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-hayden authored Nov 13, 2019
2 parents 96d0939 + d12be61 commit 1e4cb3e
Show file tree
Hide file tree
Showing 182 changed files with 1,235 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public enum FieldType
{
NUMERIC,
STRING,
DATETIME
DATETIME,
BOOLEAN
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public enum SpecificFieldType
FULL_NAME("fullname", FieldType.STRING),
STRING("string", FieldType.STRING),
DATETIME("datetime", FieldType.DATETIME),
DATE("date",FieldType.DATETIME);
DATE("date",FieldType.DATETIME),
BOOLEAN("boolean", FieldType.BOOLEAN);

@JsonValue
private final String type;
Expand Down Expand Up @@ -69,6 +70,7 @@ public static SpecificFieldType from(String type){
case "string": return STRING;
case "datetime": return DATETIME;
case "date": return DATE;
case "boolean": return BOOLEAN;
default:
throw new IllegalStateException("No data types with type " + type);
}
Expand Down
8 changes: 4 additions & 4 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ We'll start by generating data for a trivial schema. Using your favourite text e

```json
{
"schemaVersion": "0.7",
"schemaVersion": "0.16",
"fields": [{ "name": "firstName", "type": "string" }],
"rules": []
}
Expand Down Expand Up @@ -111,7 +111,7 @@ Update the JSON profile as follows:
```json
{
"schemaVersion": "0.7",
"schemaVersion": "0.16",
"fields": [{ "name": "firstName", "type": "string" }],
"rules": [
{
Expand Down Expand Up @@ -181,7 +181,7 @@ We'll expand the example profile to add a new `age` field, a not-null integer in

```json
{
"schemaVersion": "0.7",
"schemaVersion": "0.16",
"fields": [
{ "name": "firstName", "type": "string" },
{ "name": "age", "type": "integer" }
Expand Down Expand Up @@ -228,7 +228,7 @@ Finally, we'll add a field for National Insurance number. In this case, the cons

```json
{
"schemaVersion": "0.7",
"schemaVersion": "0.16",
"fields": [
{ "name": "firstName", "type": "string" },
{ "name": "age", "type": "integer" },
Expand Down
33 changes: 29 additions & 4 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
7. [Custom Generators](#custom-generator)
1. [adding](#adding-custom-generator)
2. [using](#using-custom-generator)
3. [using as constraint](#using-custom-generator-as-constraint)

8. [Running a Profile](#Running-a-Profile)
1. [Command Line Arguments](#Command-Line-Arguments)
Expand Down Expand Up @@ -87,9 +88,9 @@ This section will walk you through creating basic profiles with which you can ge
Profiles are JSON documents consisting of three sections, the schema version, the list of fields and the rules.

- **Schema Version** - Dictates the method of serialisation of the profile in order for the generator to
interpret the profile fields and rules. The latest version is 0.7.
interpret the profile fields and rules. The latest version is
```
"schemaVersion": "0.7",
"schemaVersion": "0.16",
```
- **List of Fields** - An array of column headings is defined with unique "name" keys.
```
Expand Down Expand Up @@ -140,7 +141,7 @@ These three sections are combined to form the [complete profile](#Example-Profil
## Example Profile
{
"schemaVersion": "0.7",
"schemaVersion": "0.16",
"fields": [
{
"name": "Column 1",
Expand Down Expand Up @@ -209,6 +210,7 @@ The data type of the field. See [Data types](#Data-Types) for more on how types
* `firstname`
* `lastname`
* `fullname`
* `boolean`

This is a required property.

Expand Down Expand Up @@ -250,6 +252,12 @@ Sets the field as unique. Unique fields can not be used within [grammatical cons

# Data Types

## Boolean

Users can specify boolean data types which will take the values `true` and `false`.

Currently these types are only supported with the `equalTo` and `equalToField` constraints, for example:

## Integer/Decimal

Within a profile, users can specify two numeric data types: integer and decimal. Under the hood both of these data types are considered numeric from a point of generation but the integer type enforces a granularity of 1, see below for more information on granularity.
Expand Down Expand Up @@ -333,6 +341,8 @@ OR
{ "field": "type", "equalTo": 23 }
OR
{ "field": "type", "equalTo": "2001-02-03T04:05:06.007" }
OR
{ "field": "type", "equalTo": true }
```

Is satisfied if `field`'s value is equal to `value`
Expand Down Expand Up @@ -668,7 +678,6 @@ While it's not prohibited, wrapping conditional constraints in any other kind of




# Custom Generators
<div id="custom-generator"></div>

Expand Down Expand Up @@ -704,6 +713,22 @@ This will use the "lorem ipsum" example custom generator.

To use your own, put the name of your generator instead of "lorem ipsum"

## using Custom Generators as Constraint
<div id="using-custom-generator-as-constraint"></div>

You can also use custom generators as constraints


```javascript
{ "field": "field1", "generator": "lorem ipsum" }
```

Custom generators can be used in "anyOf" grammatical constraints, as well as in the "then" and "else" parts of conditional constraints

To combine generators with sets and equalTo, you will need to create a 'matchingFunction' when building the custom generator. Which should be a function that returns true if a value is one the custom generator could produce.

To be able negate the custom generator, or use in the 'if' section of an if then statement, you must define the 'negated Generator' when building the custom generator. Which should return values that the custom generator should not produce.

# Running a Profile
<div id="Running-a-Profile"></div>

Expand Down
2 changes: 1 addition & 1 deletion docs/user/Schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Sample file
```javascript
{
"schemaVersion": "0.7",
"schemaVersion": "0.16",
"description": "A dataset about financial products",
"fields":
[
Expand Down
2 changes: 1 addition & 1 deletion examples/a-valid-isin/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "isin",
Expand Down
2 changes: 1 addition & 1 deletion examples/actor-names/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "forename",
Expand Down
2 changes: 1 addition & 1 deletion examples/anyOf/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"rules": [
{
"rule": "rule 1",
Expand Down
1 change: 1 addition & 0 deletions examples/boolean/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A profile that generates booleans.
31 changes: 31 additions & 0 deletions examples/boolean/profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"schemaVersion": "0.14",
"fields": [
{
"name": "alwaysTrue",
"type": "boolean",
"nullable": false
},
{
"name": "alwaysFalseOrNull",
"type": "boolean",
"nullable": true
}
],
"rules": [
{
"constraints": [
{
"field": "alwaysTrue",
"equalTo": true
},
{
"not": {
"field": "alwaysFalseOrNull",
"equalToField": "alwaysTrue"
}
}
]
}
]
}
2 changes: 1 addition & 1 deletion examples/date-after/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "date",
Expand Down
2 changes: 1 addition & 1 deletion examples/datetime-after-dynamic/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "field1",
Expand Down
2 changes: 1 addition & 1 deletion examples/datetime-after/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "date",
Expand Down
2 changes: 1 addition & 1 deletion examples/datetime-equal-to-dynamic-offset/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "first",
Expand Down
2 changes: 1 addition & 1 deletion examples/datetime-equal-to-dynamic/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "first",
Expand Down
2 changes: 1 addition & 1 deletion examples/datetime-equal-to/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "date",
Expand Down
2 changes: 1 addition & 1 deletion examples/datetime-offset-working-days/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "foo",
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-trades-smaller/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "tradeId",
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-trades/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "tradeId",
Expand Down
2 changes: 1 addition & 1 deletion examples/duplicates/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "a",
Expand Down
2 changes: 1 addition & 1 deletion examples/formatting/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "decimal",
Expand Down
2 changes: 1 addition & 1 deletion examples/from-file-weighted/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "name",
Expand Down
2 changes: 1 addition & 1 deletion examples/from-file/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "name",
Expand Down
2 changes: 1 addition & 1 deletion examples/hard-contradiction-null-validation/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "Column 1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "Column 1",
Expand Down
2 changes: 1 addition & 1 deletion examples/integer-range-with-blacklist/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "an_integer",
Expand Down
2 changes: 1 addition & 1 deletion examples/integer-range/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "an_integer",
Expand Down
2 changes: 1 addition & 1 deletion examples/multiple-fields/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "field1",
Expand Down
2 changes: 1 addition & 1 deletion examples/names/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "forename",
Expand Down
2 changes: 1 addition & 1 deletion examples/partial-contradictions/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "Column 1",
Expand Down
2 changes: 1 addition & 1 deletion examples/partitioning/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "p1f1",
Expand Down
2 changes: 1 addition & 1 deletion examples/real-number-range/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "a_number",
Expand Down
2 changes: 1 addition & 1 deletion examples/regex-contains/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "first_name",
Expand Down
2 changes: 1 addition & 1 deletion examples/regex-intersect-with-blacklist/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "first_name",
Expand Down
2 changes: 1 addition & 1 deletion examples/regex-intersect/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "first_name",
Expand Down
2 changes: 1 addition & 1 deletion examples/regex/profile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaVersion": "0.15",
"schemaVersion": "0.16",
"fields": [
{
"name": "first_name",
Expand Down
Loading

0 comments on commit 1e4cb3e

Please sign in to comment.