Skip to content

Concat decorator implementation appears wrong #28

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

Closed
codeandcats opened this issue May 10, 2019 · 2 comments · Fixed by #29
Closed

Concat decorator implementation appears wrong #28

codeandcats opened this issue May 10, 2019 · 2 comments · Fixed by #29

Comments

@codeandcats
Copy link
Member

I was poking around the any constraints and noticed that Concat looks like it's possibly implemented incorrectly. As you can see schema is declared twice.

/**
 * Returns a new type that is the result of adding the rules of one type to another.
 */
export function Concat(schema : Schema) : PropertyDecorator {
    return constraintDecorator([], (schema : Schema) => {
        return schema.concat(schema);
    });
}

I suspect this should be:

/**
 * Returns a new type that is the result of adding the rules of one type to another.
 */
export function Concat(schema : Schema) : PropertyDecorator {
    return constraintDecorator([], (existingSchema : Schema) => {
        return existingSchema.concat(schema);
    });
}

Empty seems to be the same:

/**
 * Outputs the original untouched value instead of the casted value.
 */
export function Empty(schema : any) : PropertyDecorator {
    return constraintDecorator([], (schema : Schema) => {
        return schema.empty(schema);
    });
}

@laurence-myers if you agree I'm happy to create a PR with the fix.

@laurence-myers
Copy link
Member

Good catch! PR would be welcome.

@laurence-myers
Copy link
Member

Fixed in v0.0.12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants