2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-06-08 16:38:52 -07:00
|
|
|
import {Pipe, PipeTransform} from '@angular/core';
|
|
|
|
import {isBlank, isString} from '../facade/lang';
|
2015-08-07 11:41:38 -07:00
|
|
|
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
|
|
|
|
2016-06-08 16:38:52 -07:00
|
|
|
|
2015-05-14 10:14:26 -07:00
|
|
|
/**
|
2015-11-02 15:46:59 -08:00
|
|
|
* Transforms text to lowercase.
|
2015-05-14 10:14:26 -07:00
|
|
|
*
|
2015-10-19 15:37:32 +01:00
|
|
|
* ### Example
|
2015-05-14 10:14:26 -07:00
|
|
|
*
|
2015-11-02 15:46:59 -08:00
|
|
|
* {@example core/pipes/ts/lowerupper_pipe/lowerupper_pipe_example.ts region='LowerUpperPipe'}
|
2016-05-27 11:24:05 -07:00
|
|
|
*
|
2016-08-23 13:58:41 -07:00
|
|
|
* @stable
|
2015-05-14 10:14:26 -07:00
|
|
|
*/
|
2015-08-07 11:41:38 -07:00
|
|
|
@Pipe({name: 'lowercase'})
|
2015-08-12 12:04:54 -07:00
|
|
|
export class LowerCasePipe implements PipeTransform {
|
2016-04-22 15:33:32 -07:00
|
|
|
transform(value: string): string {
|
2015-08-06 10:39:02 -07:00
|
|
|
if (isBlank(value)) return value;
|
|
|
|
if (!isString(value)) {
|
|
|
|
throw new InvalidPipeArgumentException(LowerCasePipe, value);
|
|
|
|
}
|
2015-10-31 13:04:26 -07:00
|
|
|
return value.toLowerCase();
|
2015-05-14 10:14:26 -07:00
|
|
|
}
|
|
|
|
}
|