Rename all convertValues functions as parseValues#219
Merged
joneubank merged 1 commit intofeat/validations-refactorfrom Jul 26, 2024
Merged
Rename all convertValues functions as parseValues#219joneubank merged 1 commit intofeat/validations-refactorfrom
convertValues functions as parseValues#219joneubank merged 1 commit intofeat/validations-refactorfrom
Conversation
6b92382 to
5e83f64
Compare
joneubank
added a commit
that referenced
this pull request
Jul 27, 2024
…215) * Move restrictions and data value types to dedicated files * Add test folders to TS path but exclude from build * Undefined checks where unchecked index access was done * Rename rangeToSymbol as rangeToText, change text priority to describe more restrictive conditions * Range checking utiltiy function with tests It should be mentioned here that the previously committed version of this had a mix up with the exclusive conditions, where the edge cases (value equal to the edge of the range) was incorrectly valdiated in the version imported from js-lectern-client. This is fixed now with tests to check these cases. * Generalize isArray type predicates, move isDefined to common * Add test folders to TS path but exclude from build * FieldRestriction type map and more granular codeList types * Move shared type definition to commonTypes * Use updated restriciton and name types in dictionary defs * Declare separate types for singular and array data record values * Code autoformatting * First pass types for reporting field resriction validation errors * Utility to convert a restriction test on a single value to apply to a whole array * Rewrite restriction validation functions to apply to single fields instead of data records * Simplify type selection * Fix edge case tests and work for isWithinRange * Documentation on process for refactored fieldValidation process * Fix generate script organization within monorepo * Refactor fieldValidation to handle each field individually Original implementation had record processing logic built into the restriction test logic. This refactor sepearates restriction tests to apply to a specific value only, based on the defined restriction rule. This will enable future development to resolve the restrictions on each field based on conditional restrictions and then test based on the resolved conditions. The next step is to add validation testing for full data records, full entity data sets, and then full dictionary data sets. These each loop over the previous element but also introduce new tests. For example, entity data sets enforce unique field and uniqueKey restrictions. Dictionary datasets enforce foreignKey restrictions. Unit tests have been added to fieldValidation function, and to the individual restriction tests. The restriction tests check the detailed set of values vs restriction rules, while the fieldValidation testing is checking that these restrictions are enforced based on schemaField definitions. Note that script validations are not being run in this code, and that the unique constraint cannot be applied to a field. There is additional changes required to move the unique constraint to a field level property (like isArray) so that it can't be affected by conditional restrictions. It will be validated in the Schema level validation (entity dataset). * WIP Documentation for Important Concepts * Move field validation code to `/validateField` * Add validateRecord functionality with basic documentation * Move validateField tests to directory matching source directory name * Tests for validateRecord * Editing TSDoc for validation type utils * Complete pnpm monorepo registration for scripts module * Infer predicates instead of declaring where possible * Create function `validateSchema` to validate a list of records with single schema Applies the `validateRecord` validation to every record, plus runs validations that require knowledge of the entire set of records for this schema: - unique - uniqueKey * Add copyright declaration to top of files * Clean regex test error message by removing the rule * Update test description text for rangeTest to match other tests * Test for validateSchema valid and unique restriction - fixes bug in testUniqueFieldRestriction that was using the wrong field name when generating the hash - adds DataSetHashMap type alias that was missing in previous commit - adds test utility to validate that test fixtures are valid vs the Lectern zod schemas * Add tests for uniqueKey restriction in validateSchema * Add tests for validateSchema uniqueKey with undefined values * Add tests for validateSchema to ensure it tests record and field restrictions * Update uniqueKey invalid test to check error detailed properties * Organize imports * Add `validateDictionary` function plus related tests and fixtures - applies foreign key restrictions - detects unrecognized schemas - collects foreign key errors with other record errors * Standardize test fixture validation message text * Remove range rule from test failure message * Add period to required test failure message * Move `resolveFieldRestrictions` function to its own file * Rename foreign key type and schema to `ForeignKeyRestriction` * Rename testField/restriction specs to match source file names * Remove empty spec files * Add copyright text to test fixtures * Result type can have Failure data, remove `Either` type * Add convertValue functionality - functions for converting values for field, record, schema, and dictionary - update to validation error type names to be shared with convert value types - includes test specs for each convert function exported * Fix simple typos * Update client processing functions to use new validation functions * Remove validation tests from client that are now done in validation package * Unique restriction rules enforced for array fields * Remove deprecated types and test implementations from legacy client * Remove old data conversion implementation from client processing * Remove old data valdiation pipeline from client processing * Remove tests around non-standard default value setting * Test fixtures for unique restrictions with arrays * Update property names in RecordError and TestResult types (#216) * Change `FieldDetails` property `value` to `fieldValue` * Change TestResult invalid property to be `details` * Rename convert functions as parse (#219)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This improves naming clarity by describing the first stage in data processing as "Parsing" values instead of naming this process "Converting" values. The distinction is that the values are not being modified, they are simply being parsed from strings into the types defined in the schema.