Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Validation from JavaScript Implementation #5

Closed
mttrbrts opened this issue Aug 1, 2022 · 0 comments · Fixed by #29
Closed

Port Validation from JavaScript Implementation #5

mttrbrts opened this issue Aug 1, 2022 · 0 comments · Fixed by #29
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mttrbrts
Copy link
Member

mttrbrts commented Aug 1, 2022

Feature Request 🛍️

To mirror the functional API for Concerto, we need to implement validation of a JSON object against a model definition.

Use Case

Validation is a key operation of a schema language, and is used to determine whether data is valid with respect to the model and the language specification.

Possible Solution

The existing (empty) AccordProject.Concerto namespace should have a public class added that contains a validate operation with the following signature:

    public void validate(String jsonObject, ObjectValidatorOptions options) {
        //...
    }

Note that this is not a binary operation, i.e. there is no true/false response depending on the outcome of validation. Instead, a validation of a valid object will return successfully and validation of an invalid object will throw an exception that contains details of why the validation failed.

Context

The reference implementation for this is in the JS version of Concerto.

It is critical that implementations of Concerto for different runtimes have the same semantics and very close signatures. Extensions to the language should be avoided until parity is achieved with the JS implementation. It is expected that the JS implementation will continue to be the reference implementation for some time.

Detailed Description

A proper implementation of validation will also require porting of the ModelManager and associated introspection Classes (see #4).

Existing unit tests, which should be ported

Dates are specified according to the ISO 8601 standard. We adopt the DayJS library which supports the following formats This spec must be respected in the .NET port. All of the following are valid date formats in Concerto.

YYYY-MM-DDTHH:MM:SS.000+hh:mm
YYYY-MM-DDTHH:MM:SS.000+hhmm
YYYY-MM-DDTHH:MM:SS.000Z
YYYY-MM-DDTHH:MM:SS.000
YYYY-MM-DDTHH:MM:SS
YYYY-MM-DDTHH:MM:SSZ
YYYY-MM-DD
YYYY-MM
YYYYMMDD
YYYYMMDDTHHMMSS

Regular expressions use the ECMAScript flavour, any validation of Regular Expressions in field validators should be performed in ECMAScript compatibility mode.

Error messages and console logs must not include any values from the input data, e.g. accordproject/concerto#483

@mttrbrts mttrbrts added enhancement New feature or request good first issue Good for newcomers labels Sep 2, 2022
@mttrbrts mttrbrts moved this to In Progress in Concerto Roadmap Nov 8, 2023
@mttrbrts mttrbrts moved this from In Progress to Next 3 Months in Concerto Roadmap Nov 8, 2023
@github-project-automation github-project-automation bot moved this from Next 3 Months to Done in Concerto Roadmap Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants