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

Simplify ensure() by using the keyof operator #485

Open
TimVevida opened this issue Apr 19, 2018 · 0 comments · May be fixed by #486
Open

Simplify ensure() by using the keyof operator #485

TimVevida opened this issue Apr 19, 2018 · 0 comments · May be fixed by #486

Comments

@TimVevida
Copy link

I'm submitting a feature request

  • Library Version:
    1.1.2

Please tell us about your environment:

  • Operating System:
    Linux (kubuntu)

  • Node Version:
    6.14.1

  • NPM Version:
    3.10.10
  • JSPM Version
    JSPM 0.16.53
  • Language:
    TypeScript 2.8.1

Current behavior:
ValidationRules.ensure(...) accepts both a string or a function. The string should be a property name, and the function should return the property. We are using a function to make use of the Typescript type checking. However, in our code coverage, these functions are mentioned as not being covered by the component tests. This is because the function is never actually executed, but parsed in the PropertyAccessorParser.

Desired behavior:
An easy solution would be to make the ensure(...) argument a keyof TObject. This would both cover the need for type checking and remove the need for a function parser.

TimVevida pushed a commit to TimVevida/validation that referenced this issue Apr 20, 2018
the keyof operator.

Calls to .ensure() allowed both a string and a function as argument. The
function was never actually executed, but parsed to get the string
property name. The same effect can be achieved by using the keyof
operator. In this case, only strings can be provided that are a property
of the given class.

Initial version, requiring the programmer to explicitly state the object
class each time .ensure() is executed. This is because .ensure() is a
static function, so the type cannot be determined yet.

Fixes aurelia#485.
TimVevida pushed a commit to TimVevida/validation that referenced this issue Apr 20, 2018
the keyof operator.

Calls to .ensure() allowed both a string and a function as argument. The
function was never actually executed, but parsed to get the string
property name. The same effect can be achieved by using the keyof
operator. In this case, only strings can be provided that are a property
of the given class.

Initial version, requiring the programmer to explicitly state the object
class each time .ensure() is executed. This is because .ensure() is a
static function, so the type cannot be determined yet.

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

Successfully merging a pull request may close this issue.

1 participant