ATSCALE-22101
Relationships
Types
IYamlDimensionRelationship
IYamlModelRelationship
IYamlModelRegularRelationship | IYamlModelSecurityRelationship
IYamlDimensionRegularRelationship | IYamlSecurityRelationship
IYamlSnowflakeRelationship | IYamlEmbeddedRelationship | IYamlSecurityRelationship
All Inherit
- IUniqueNameObject
All possess
- from
- to
conditionally contain
- type
All Inherit
- IUniqueNameObject
All possess
- from
- to
conditionally contain
- type
validation
YamlSchemaValidatorWrapper contains a SchemaValidator which applies JSON validation
Our desired process
- Clone file
- Extract undesired properties (i.e. orphan relationships)
- Validate desired properties
- Attach appropriate errors for the "undesired properties"
- Return a validationOutputResult
What we have implemented
clone file
extract undesired properties
validate desired properties
attach errors
returning original error result
We just return the result we have modified above
ValidateValidationResult
Params
- Validation Result
- Is validation result pure function or boolean
- Transform validation result pure function
- list of undesired properties
- clone of original file
Process
1.
2.
validation result is a boolean (indicating we passed "result.isValid")
we should return the original result.
Validation result is a function
We should call it on the result and see if it is valid
Result is not valid
Result is valid
We return the result itself as the undesired properties either have no effect, or the validation function tell us we don't need extra errors.
We apply the transform validation result pure function on the result and return it.
We use CloneUtil to Deep clone
We have constructed the following functions to facilitate
applyFilterFn(params: {result, undesiredPRoperties, file} ) => IYamlObjectSchemaValidatorResponse
filterRelationshipsFromModel(model) =>IYamlObjectSchemaValidatorResponse
As well as similar Fns for dimensions
We have defined 2 validate validation result functions for model and dimension result validation
There is an "applyErrors" function which is used by the transform functions for model and dimension to apply errors passed to it.
Questions
What type of relationships do we have?
Models and Dimensions
When validating dimensions or model relationships:
Are the defined interfaces we have "sources of truth"?
Can I make my validation functions around these interfaces, or are there "validation rules" documented somewhere for these objects.
Why is there a test that says:
For each IYamlRelationType enum: we should receive NO errors.
Reference
`` EnumUtil.getAllValues(YamlDimensionRelationType).forEach((t) => {
it(
Should return NO error if relation type is "${t}"`, () => {
const parsedFile = YamlDimensionBuilder.create()
.addRelationship({ type: t as YamlDimensionRelationType })
.buildYamlFile();
const result = validateAML(parsedFile);
expect(result.isValid).toBe(true);
expect(result.errors?.length).toBe(0);
});
});```
packages/compiler/src/YamlObjectSchemaValidator/YamlDimensionSchemaValidator/YamlDimensionSchemaValidator.test.ts